diff --git a/servo/components/fallible/lib.rs b/servo/components/fallible/lib.rs index ae6a40dc789d..f807bc9ce7a6 100644 --- a/servo/components/fallible/lib.rs +++ b/servo/components/fallible/lib.rs @@ -5,9 +5,9 @@ extern crate hashglobe; extern crate smallvec; -use hashglobe::FailedAllocationError; #[cfg(feature = "known_system_malloc")] use hashglobe::alloc; +use hashglobe::FailedAllocationError; use smallvec::Array; use smallvec::SmallVec; use std::vec::Vec; diff --git a/servo/components/hashglobe/src/fake.rs b/servo/components/hashglobe/src/fake.rs index c5cd9d39bb75..d2cdd549e48d 100644 --- a/servo/components/hashglobe/src/fake.rs +++ b/servo/components/hashglobe/src/fake.rs @@ -20,8 +20,8 @@ use std::fmt; use std::hash::{BuildHasher, Hash}; use std::ops::{Deref, DerefMut}; -pub use std::collections::hash_map::{Entry, RandomState, Iter as MapIter, IterMut as MapIterMut}; -pub use std::collections::hash_set::{Iter as SetIter, IntoIter as SetIntoIter}; +pub use std::collections::hash_map::{Entry, Iter as MapIter, IterMut as MapIterMut, RandomState}; +pub use std::collections::hash_set::{IntoIter as SetIntoIter, Iter as SetIter}; #[derive(Clone)] pub struct HashMap(StdMap); diff --git a/servo/components/hashglobe/src/hash_map.rs b/servo/components/hashglobe/src/hash_map.rs index 57ac9bcc049c..03ade951e1ec 100644 --- a/servo/components/hashglobe/src/hash_map.rs +++ b/servo/components/hashglobe/src/hash_map.rs @@ -15,13 +15,13 @@ use std::borrow::Borrow; use std::cmp::max; use std::fmt::{self, Debug}; #[allow(deprecated)] -use std::hash::{Hash, BuildHasher}; +use std::hash::{BuildHasher, Hash}; use std::iter::FromIterator; use std::mem::{self, replace}; use std::ops::{Deref, Index}; -use super::table::{self, Bucket, EmptyBucket, FullBucket, FullBucketMut, RawTable, SafeHash}; use super::table::BucketState::{Empty, Full}; +use super::table::{self, Bucket, EmptyBucket, FullBucket, FullBucketMut, RawTable, SafeHash}; use FailedAllocationError; @@ -2214,11 +2214,11 @@ fn assert_covariance() { #[cfg(test)] mod test_map { extern crate rand; - use super::HashMap; + use self::rand::{thread_rng, Rng}; use super::Entry::{Occupied, Vacant}; + use super::HashMap; use super::RandomState; use cell::RefCell; - use self::rand::{thread_rng, Rng}; #[test] fn test_zero_capacities() { diff --git a/servo/components/hashglobe/src/hash_set.rs b/servo/components/hashglobe/src/hash_set.rs index 34e657e44fcc..694e01c46eb8 100644 --- a/servo/components/hashglobe/src/hash_set.rs +++ b/servo/components/hashglobe/src/hash_set.rs @@ -10,12 +10,12 @@ use std::borrow::Borrow; use std::fmt; -use std::hash::{Hash, BuildHasher}; +use std::hash::{BuildHasher, Hash}; use std::iter::{Chain, FromIterator}; -use std::ops::{BitOr, BitAnd, BitXor, Sub}; +use std::ops::{BitAnd, BitOr, BitXor, Sub}; -use super::Recover; use super::hash_map::{self, HashMap, Keys, RandomState}; +use super::Recover; // Future Optimization (FIXME!) // ============================= @@ -1258,8 +1258,8 @@ fn assert_covariance() { #[cfg(test)] mod test_set { - use super::HashSet; use super::hash_map::RandomState; + use super::HashSet; #[test] fn test_zero_capacities() { diff --git a/servo/components/hashglobe/src/table.rs b/servo/components/hashglobe/src/table.rs index 0b8b49001e2d..15e3394884ff 100644 --- a/servo/components/hashglobe/src/table.rs +++ b/servo/components/hashglobe/src/table.rs @@ -9,13 +9,13 @@ // except according to those terms. use alloc::{alloc, dealloc}; +use shim::{Shared, Unique}; use std::cmp; use std::hash::{BuildHasher, Hash, Hasher}; use std::marker; use std::mem::{self, align_of, size_of}; use std::ops::{Deref, DerefMut}; use std::ptr; -use shim::{Unique, Shared}; use self::BucketState::*; use FailedAllocationError; diff --git a/servo/components/malloc_size_of/lib.rs b/servo/components/malloc_size_of/lib.rs index e0f638a843d2..69dc48ce30d3 100644 --- a/servo/components/malloc_size_of/lib.rs +++ b/servo/components/malloc_size_of/lib.rs @@ -82,8 +82,8 @@ extern crate xml5ever; use serde_bytes::ByteBuf; use std::hash::{BuildHasher, Hash}; use std::mem::size_of; -use std::ops::{Deref, DerefMut}; use std::ops::Range; +use std::ops::{Deref, DerefMut}; use std::os::raw::c_void; use void::Void; @@ -557,6 +557,36 @@ where } } +impl MallocShallowSizeOf for std::collections::BTreeMap +where + K: Eq + Hash, +{ + fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + if ops.has_malloc_enclosing_size_of() { + self.values() + .next() + .map_or(0, |v| unsafe { ops.malloc_enclosing_size_of(v) }) + } else { + self.len() * (size_of::() + size_of::() + size_of::()) + } + } +} + +impl MallocSizeOf for std::collections::BTreeMap +where + K: Eq + Hash + MallocSizeOf, + V: MallocSizeOf, +{ + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + let mut n = self.shallow_size_of(ops); + for (k, v) in self.iter() { + n += k.size_of(ops); + n += v.size_of(ops); + } + n + } +} + impl MallocShallowSizeOf for hashglobe::hash_map::HashMap where K: Eq + Hash, diff --git a/servo/components/malloc_size_of_derive/lib.rs b/servo/components/malloc_size_of_derive/lib.rs index 59446131508f..dc0d34af88fe 100644 --- a/servo/components/malloc_size_of_derive/lib.rs +++ b/servo/components/malloc_size_of_derive/lib.rs @@ -88,7 +88,8 @@ fn malloc_size_of_derive(s: synstructure::Structure) -> quote::Tokens { fn test_struct() { let source = syn::parse_str( "struct Foo { bar: Bar, baz: T, #[ignore_malloc_size_of = \"\"] z: Arc }", - ).unwrap(); + ) + .unwrap(); let source = synstructure::Structure::new(&source); let expanded = malloc_size_of_derive(source).to_string(); diff --git a/servo/components/selectors/builder.rs b/servo/components/selectors/builder.rs index b17ed9bfc63c..8fcca8f78e25 100644 --- a/servo/components/selectors/builder.rs +++ b/servo/components/selectors/builder.rs @@ -23,7 +23,7 @@ use sink::Push; use smallvec::{self, SmallVec}; use std::cmp; use std::iter; -use std::ops::{AddAssign, Add}; +use std::ops::{Add, AddAssign}; use std::ptr; use std::slice; diff --git a/servo/components/selectors/matching.rs b/servo/components/selectors/matching.rs index ef0c6563f3ca..ef942708873c 100644 --- a/servo/components/selectors/matching.rs +++ b/servo/components/selectors/matching.rs @@ -588,7 +588,8 @@ where element.is_html_element_in_html_document(), &local_name.name, &local_name.lower_name, - ).borrow(); + ) + .borrow(); element.local_name() == name } diff --git a/servo/components/selectors/parser.rs b/servo/components/selectors/parser.rs index 3e82a49b348b..0709c4eef998 100644 --- a/servo/components/selectors/parser.rs +++ b/servo/components/selectors/parser.rs @@ -8,10 +8,10 @@ use attr::{ParsedCaseSensitivity, SELECTOR_WHITESPACE}; use bloom::BLOOM_HASH_MASK; use builder::{SelectorBuilder, SpecificityAndFlags}; use context::QuirksMode; +use cssparser::{parse_nth, serialize_identifier}; use cssparser::{BasicParseError, BasicParseErrorKind, ParseError, ParseErrorKind}; use cssparser::{CowRcStr, Delimiter, SourceLocation}; use cssparser::{CssStringWriter, Parser as CssParser, ToCss, Token}; -use cssparser::{parse_nth, serialize_identifier}; use precomputed_hash::PrecomputedHash; use servo_arc::ThinArc; use sink::Push; @@ -270,7 +270,9 @@ where // Ensure they're actually all compound selectors without pseudo-elements. if selector.has_pseudo_element() { - return Err(location.new_custom_error(SelectorParseErrorKind::PseudoElementInComplexSelector)); + return Err( + location.new_custom_error(SelectorParseErrorKind::PseudoElementInComplexSelector) + ); } if selector.iter_raw_match_order().any(|s| s.is_combinator()) { @@ -457,7 +459,7 @@ where ) { return false; } - }, + } AttributeOther(ref attr_selector) if !attr_selector.never_matches => { let empty_string; let namespace = match attr_selector.namespace() { @@ -1720,7 +1722,8 @@ where if namespace.is_none() && include!(concat!( env!("OUT_DIR"), "/ascii_case_insensitive_html_attributes.rs" - )).contains(&*local_name_lower_cow) + )) + .contains(&*local_name_lower_cow) { case_sensitivity = ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument @@ -1872,33 +1875,30 @@ where SimpleSelectorParseResult::PseudoElement(p) => { slotted_selector = None; pseudo_element = Some(p); - } + }, SimpleSelectorParseResult::SlottedPseudo(selector) => { slotted_selector = Some(selector); - let maybe_pseudo = parse_one_simple_selector( - parser, - input, - /* inside_negation = */ false, - )?; + let maybe_pseudo = + parse_one_simple_selector(parser, input, /* inside_negation = */ false)?; pseudo_element = match maybe_pseudo { None => None, Some(SimpleSelectorParseResult::PseudoElement(pseudo)) => { if !pseudo.valid_after_slotted() { return Err(input.new_custom_error( - SelectorParseErrorKind::InvalidPseudoElementAfterSlotted + SelectorParseErrorKind::InvalidPseudoElementAfterSlotted, )); } Some(pseudo) - } + }, Some(SimpleSelectorParseResult::SimpleSelector(..)) | Some(SimpleSelectorParseResult::SlottedPseudo(..)) => { return Err(input.new_custom_error( - SelectorParseErrorKind::NonPseudoElementAfterSlotted + SelectorParseErrorKind::NonPseudoElementAfterSlotted, )); - } + }, }; - } + }, } debug_assert!(slotted_selector.is_some() || pseudo_element.is_some()); @@ -1925,14 +1925,12 @@ where let name = match input.next_including_whitespace()? { &Token::Ident(ref name) => name.clone(), t => { - return Err(location.new_custom_error( - SelectorParseErrorKind::NoIdentForPseudo(t.clone()), - )) + return Err(location + .new_custom_error(SelectorParseErrorKind::NoIdentForPseudo(t.clone()))) }, }; - let pseudo_class = - P::parse_non_ts_pseudo_class(parser, location, name.clone())?; + let pseudo_class = P::parse_non_ts_pseudo_class(parser, location, name.clone())?; if !p.supports_pseudo_class(&pseudo_class) { return Err(input.new_custom_error( SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name), @@ -2139,7 +2137,8 @@ where "last-of-type" => Ok(Component::LastOfType), "only-of-type" => Ok(Component::OnlyOfType), _ => Err(()) - }).or_else(|()| { + }) + .or_else(|()| { P::parse_non_ts_pseudo_class(parser, location, name).map(Component::NonTSPseudoClass) }) } @@ -2147,12 +2146,12 @@ where // NB: pub module in order to access the DummyParser #[cfg(test)] pub mod tests { + use super::*; use builder::HAS_PSEUDO_BIT; use cssparser::{serialize_identifier, Parser as CssParser, ParserInput, ToCss}; use parser; use std::collections::HashMap; use std::fmt; - use super::*; #[derive(Clone, Debug, Eq, PartialEq)] pub enum PseudoClass { @@ -2422,9 +2421,9 @@ pub mod tests { vec![Component::LocalName(LocalName { name: DummyAtom::from("EeÉ"), lower_name: DummyAtom::from("eeÉ"), - }), ], + })], specificity(0, 0, 1), - ), ])) + )])) ); assert_eq!( parse("|e"), @@ -2437,7 +2436,7 @@ pub mod tests { }), ], specificity(0, 0, 1), - ), ])) + )])) ); // When the default namespace is not set, *| should be elided. // https://github.com/servo/servo/pull/17537 @@ -2447,9 +2446,9 @@ pub mod tests { vec![Component::LocalName(LocalName { name: DummyAtom::from("e"), lower_name: DummyAtom::from("e"), - }), ], + })], specificity(0, 0, 1), - ), ])) + )])) ); // When the default namespace is set, *| should _not_ be elided (as foo // is no longer equivalent to *|foo--the former is only for foo in the @@ -2469,14 +2468,14 @@ pub mod tests { }), ], specificity(0, 0, 1), - ), ])) + )])) ); assert_eq!( parse("*"), Ok(SelectorList::from_vec(vec![Selector::from_vec( vec![Component::ExplicitUniversalType], specificity(0, 0, 0) - ), ])) + )])) ); assert_eq!( parse("|*"), @@ -2486,14 +2485,14 @@ pub mod tests { Component::ExplicitUniversalType, ], specificity(0, 0, 0), - ), ])) + )])) ); assert_eq!( parse_expected("*|*", Some("*")), Ok(SelectorList::from_vec(vec![Selector::from_vec( vec![Component::ExplicitUniversalType], specificity(0, 0, 0) - ), ])) + )])) ); assert_eq!( parse_ns( @@ -2506,7 +2505,7 @@ pub mod tests { Component::ExplicitUniversalType, ], specificity(0, 0, 0), - ), ])) + )])) ); assert_eq!( parse(".foo:lang(en-US)"), @@ -2516,14 +2515,14 @@ pub mod tests { Component::NonTSPseudoClass(PseudoClass::Lang("en-US".to_owned())), ], specificity(0, 2, 0), - ), ])) + )])) ); assert_eq!( parse("#bar"), Ok(SelectorList::from_vec(vec![Selector::from_vec( vec![Component::ID(DummyAtom::from("bar"))], specificity(1, 0, 0), - ), ])) + )])) ); assert_eq!( parse("e.foo#bar"), @@ -2537,7 +2536,7 @@ pub mod tests { Component::ID(DummyAtom::from("bar")), ], specificity(1, 1, 1), - ), ])) + )])) ); assert_eq!( parse("e.foo #bar"), @@ -2552,7 +2551,7 @@ pub mod tests { Component::ID(DummyAtom::from("bar")), ], specificity(1, 1, 1), - ), ])) + )])) ); // Default namespace does not apply to attribute selectors // https://github.com/mozilla/servo/pull/1652 @@ -2563,9 +2562,9 @@ pub mod tests { vec![Component::AttributeInNoNamespaceExists { local_name: DummyAtom::from("Foo"), local_name_lower: DummyAtom::from("foo"), - }, ], + }], specificity(0, 1, 0), - ), ])) + )])) ); assert!(parse_ns("svg|circle", &parser).is_err()); parser @@ -2582,7 +2581,7 @@ pub mod tests { }), ], specificity(0, 0, 1), - ), ])) + )])) ); assert_eq!( parse_ns("svg|*", &parser), @@ -2592,7 +2591,7 @@ pub mod tests { Component::ExplicitUniversalType, ], specificity(0, 0, 0), - ), ])) + )])) ); // Default namespace does not apply to attribute selectors // https://github.com/mozilla/servo/pull/1652 @@ -2610,7 +2609,7 @@ pub mod tests { }, ], specificity(0, 1, 0), - ), ])) + )])) ); // Default namespace does apply to type selectors assert_eq!( @@ -2624,7 +2623,7 @@ pub mod tests { }), ], specificity(0, 0, 1), - ), ])) + )])) ); assert_eq!( parse_ns("*", &parser), @@ -2634,7 +2633,7 @@ pub mod tests { Component::ExplicitUniversalType, ], specificity(0, 0, 0), - ), ])) + )])) ); assert_eq!( parse_ns("*|*", &parser), @@ -2644,7 +2643,7 @@ pub mod tests { Component::ExplicitUniversalType, ], specificity(0, 0, 0), - ), ])) + )])) ); // Default namespace applies to universal and type selectors inside :not and :matches, // but not otherwise. @@ -2660,7 +2659,7 @@ pub mod tests { ), ], specificity(0, 1, 0), - ), ])) + )])) ); assert_eq!( parse_ns(":not(*)", &parser), @@ -2671,12 +2670,13 @@ pub mod tests { vec![ Component::DefaultNamespace(MATHML.into()), Component::ExplicitUniversalType, - ].into_boxed_slice() + ] + .into_boxed_slice() .into(), ), ], specificity(0, 0, 0), - ), ])) + )])) ); assert_eq!( parse_ns(":not(e)", &parser), @@ -2690,12 +2690,13 @@ pub mod tests { name: DummyAtom::from("e"), lower_name: DummyAtom::from("e"), }), - ].into_boxed_slice() + ] + .into_boxed_slice() .into(), ), ], specificity(0, 0, 1), - ), ])) + )])) ); assert_eq!( parse("[attr|=\"foo\"]"), @@ -2706,9 +2707,9 @@ pub mod tests { value: DummyAtom::from("foo"), never_matches: false, case_sensitivity: ParsedCaseSensitivity::CaseSensitive, - }, ], + }], specificity(0, 1, 0), - ), ])) + )])) ); // https://github.com/mozilla/servo/issues/1723 assert_eq!( @@ -2716,7 +2717,7 @@ pub mod tests { Ok(SelectorList::from_vec(vec![Selector::from_vec( vec![Component::PseudoElement(PseudoElement::Before)], specificity(0, 0, 1) | HAS_PSEUDO_BIT, - ), ])) + )])) ); assert_eq!( parse("::before:hover"), @@ -2726,7 +2727,7 @@ pub mod tests { Component::NonTSPseudoClass(PseudoClass::Hover), ], specificity(0, 1, 1) | HAS_PSEUDO_BIT, - ), ])) + )])) ); assert_eq!( parse("::before:hover:hover"), @@ -2737,7 +2738,7 @@ pub mod tests { Component::NonTSPseudoClass(PseudoClass::Hover), ], specificity(0, 2, 1) | HAS_PSEUDO_BIT, - ), ])) + )])) ); assert!(parse("::before:hover:active").is_err()); assert!(parse("::before:hover .foo").is_err()); @@ -2760,7 +2761,7 @@ pub mod tests { Component::PseudoElement(PseudoElement::After), ], specificity(0, 0, 2) | HAS_PSEUDO_BIT, - ), ])) + )])) ); assert_eq!( parse("#d1 > .ok"), @@ -2771,7 +2772,7 @@ pub mod tests { Component::Class(DummyAtom::from("ok")), ], (1 << 20) + (1 << 10) + (0 << 0), - ), ])) + )])) ); parser.default_ns = None; assert!(parse(":not(#provel.old)").is_err()); @@ -2784,9 +2785,9 @@ pub mod tests { vec![Component::ID(DummyAtom::from("provel"))] .into_boxed_slice() .into(), - ), ], + )], specificity(1, 0, 0), - ), ])) + )])) ); assert_eq!( parse_ns(":not(svg|circle)", &parser), @@ -2798,11 +2799,12 @@ pub mod tests { name: DummyAtom::from("circle"), lower_name: DummyAtom::from("circle"), }), - ].into_boxed_slice() + ] + .into_boxed_slice() .into(), - ), ], + )], specificity(0, 0, 1), - ), ])) + )])) ); // https://github.com/servo/servo/issues/16017 assert_eq!( @@ -2812,9 +2814,9 @@ pub mod tests { vec![Component::ExplicitUniversalType] .into_boxed_slice() .into(), - ), ], + )], specificity(0, 0, 0), - ), ])) + )])) ); assert_eq!( parse_ns(":not(|*)", &parser), @@ -2823,11 +2825,12 @@ pub mod tests { vec![ Component::ExplicitNoNamespace, Component::ExplicitUniversalType, - ].into_boxed_slice() + ] + .into_boxed_slice() .into(), - ), ], + )], specificity(0, 0, 0), - ), ])) + )])) ); // *| should be elided if there is no default namespace. // https://github.com/servo/servo/pull/17537 @@ -2838,9 +2841,9 @@ pub mod tests { vec![Component::ExplicitUniversalType] .into_boxed_slice() .into(), - ), ], + )], specificity(0, 0, 0), - ), ])) + )])) ); assert_eq!( parse_ns(":not(svg|*)", &parser), @@ -2849,11 +2852,12 @@ pub mod tests { vec![ Component::Namespace(DummyAtom("svg".into()), SVG.into()), Component::ExplicitUniversalType, - ].into_boxed_slice() + ] + .into_boxed_slice() .into(), - ), ], + )], specificity(0, 0, 0), - ), ])) + )])) ); assert!(parse("::slotted()").is_err()); @@ -2891,7 +2895,8 @@ pub mod tests { let selector = &parse_ns( "*|*::before", &DummyParser::default_with_namespace(DummyAtom::from("https://mozilla.org")), - ).unwrap() + ) + .unwrap() .0[0]; assert!(selector.is_universal()); } diff --git a/servo/components/selectors/tree.rs b/servo/components/selectors/tree.rs index 9db190c81097..1e899f221045 100644 --- a/servo/components/selectors/tree.rs +++ b/servo/components/selectors/tree.rs @@ -22,7 +22,9 @@ impl OpaqueElement { /// Creates a new OpaqueElement from an arbitrarily-typed pointer. pub fn new(ptr: &T) -> Self { unsafe { - OpaqueElement(NonNull::new_unchecked(ptr as *const T as *const () as *mut ())) + OpaqueElement(NonNull::new_unchecked( + ptr as *const T as *const () as *mut (), + )) } } } diff --git a/servo/components/servo_arc/lib.rs b/servo/components/servo_arc/lib.rs index 05296165acc2..1a80f057b9b4 100644 --- a/servo/components/servo_arc/lib.rs +++ b/servo/components/servo_arc/lib.rs @@ -32,7 +32,6 @@ use nodrop::NoDrop; #[cfg(feature = "servo")] use serde::{Deserialize, Serialize}; use stable_deref_trait::{CloneStableDeref, StableDeref}; -use std::{isize, usize}; use std::borrow; use std::cmp::Ordering; use std::convert::From; @@ -48,6 +47,7 @@ use std::ptr; use std::slice; use std::sync::atomic; use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; +use std::{isize, usize}; // Private macro to get the offset of a struct field in bytes from the address of the struct. macro_rules! offset_of { @@ -1170,11 +1170,11 @@ impl fmt::Debug for ArcUnion { #[cfg(test)] mod tests { + use super::{Arc, HeaderWithLength, ThinArc}; use std::clone::Clone; use std::ops::Drop; use std::sync::atomic; use std::sync::atomic::Ordering::{Acquire, SeqCst}; - use super::{Arc, HeaderWithLength, ThinArc}; #[derive(PartialEq)] struct Canary(*mut atomic::AtomicUsize); diff --git a/servo/components/style/animation.rs b/servo/components/style/animation.rs index 70db7c2c5b75..14ea1e21a2d0 100644 --- a/servo/components/style/animation.rs +++ b/servo/components/style/animation.rs @@ -8,15 +8,14 @@ // compile it out so that people remember it exists, thus the cfg'd Sender // import. -use Atom; use bezier::Bezier; use context::SharedStyleContext; use dom::{OpaqueNode, TElement}; use font_metrics::FontMetricsProvider; -use properties::{self, CascadeMode, ComputedValues, LonghandId}; use properties::animated_properties::AnimatedProperty; use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection; use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState; +use properties::{self, CascadeMode, ComputedValues, LonghandId}; use rule_tree::CascadeLevel; use servo_arc::Arc; #[cfg(feature = "servo")] @@ -26,12 +25,12 @@ use std::fmt; use std::sync::mpsc::Sender; use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue}; use timer::Timer; +use values::computed::box_::TransitionProperty; use values::computed::Time; use values::computed::TimingFunction; -use values::computed::box_::TransitionProperty; use values::generics::box_::AnimationIterationCount; use values::generics::easing::{StepPosition, TimingFunction as GenericTimingFunction}; - +use Atom; /// This structure represents a keyframes animation current iteration state. /// @@ -316,7 +315,8 @@ impl PropertyAnimation { old_style, new_style, ) - }).collect(), + }) + .collect(), TransitionProperty::Longhand(longhand_id) => { let animation = PropertyAnimation::from_longhand( longhand_id, @@ -367,8 +367,9 @@ impl PropertyAnimation { let mut current_step = (time * (steps as f64)).floor() as i32; if pos == StepPosition::Start || - pos == StepPosition::JumpStart || - pos == StepPosition::JumpBoth { + pos == StepPosition::JumpStart || + pos == StepPosition::JumpBoth + { current_step = current_step + 1; } @@ -472,7 +473,8 @@ pub fn start_transitions_if_applicable( duration: box_style.transition_duration_mod(i).seconds() as f64, property_animation, }, - )).unwrap(); + )) + .unwrap(); had_animations = true; } @@ -759,7 +761,8 @@ where } else { None } - }).unwrap_or(animation.steps.len() - 1); + }) + .unwrap_or(animation.steps.len() - 1); }, _ => unreachable!(), } diff --git a/servo/components/style/attr.rs b/servo/components/style/attr.rs index a3b119c3a975..158875ea327f 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 {Atom, LocalName, Namespace, Prefix}; use app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::Zero; @@ -17,10 +16,11 @@ use servo_arc::Arc; use servo_url::ServoUrl; use shared_lock::Locked; use std::str::FromStr; +use str::str_join; use str::{read_exponent, read_fraction, HTML_SPACE_CHARACTERS}; use str::{read_numbers, split_commas, split_html_space_chars}; -use str::str_join; use values::specified::Length; +use {Atom, LocalName, Namespace, Prefix}; // Duplicated from script::dom::values. const UNSIGNED_LONG_MAX: u32 = 2147483647; diff --git a/servo/components/style/build.rs b/servo/components/style/build.rs index 8de16176c346..046699c43120 100644 --- a/servo/components/style/build.rs +++ b/servo/components/style/build.rs @@ -67,7 +67,8 @@ fn find_python() -> String { "python2.7" } else { "python" - }.to_owned() + } + .to_owned() } lazy_static! { diff --git a/servo/components/style/build_gecko.rs b/servo/components/style/build_gecko.rs index eff6d94027af..1909c15330d3 100644 --- a/servo/components/style/build_gecko.rs +++ b/servo/components/style/build_gecko.rs @@ -14,6 +14,8 @@ mod common { #[cfg(feature = "bindgen")] mod bindings { + use super::super::PYTHON; + use super::common::*; use bindgen::{Builder, CodegenConfig}; use regex::Regex; use std::cmp; @@ -26,8 +28,6 @@ mod bindings { use std::slice; use std::sync::Mutex; use std::time::SystemTime; - use super::common::*; - use super::super::PYTHON; use toml; use toml::value::Table; @@ -284,7 +284,8 @@ mod bindings { let macro_name = captures.get(1).unwrap().as_str().to_string(); let type_name = captures.get(2).unwrap().as_str().to_string(); (macro_name, type_name) - }).collect() + }) + .collect() } fn get_borrowed_types() -> Vec<(bool, String)> { @@ -419,7 +420,8 @@ mod bindings { servo, if generic { "" } else { "" } )) - }).get_builder(); + }) + .get_builder(); write_binding_file(builder, STRUCTS_FILE, &fixups); } @@ -467,7 +469,8 @@ mod bindings { filter: env::var("STYLO_BUILD_FILTER") .ok() .unwrap_or_else(|| "bindgen".to_owned()), - })).expect("Failed to set logger."); + })) + .expect("Failed to set logger."); true } else { @@ -486,7 +489,8 @@ mod bindings { .handle_common(&mut fixups) .handle_str_items("whitelist-functions", |b, item| b.whitelist_function(item)) .handle_str_items("structs-types", |mut builder, ty| { - builder = builder.blacklist_type(ty) + builder = builder + .blacklist_type(ty) .raw_line(format!("use gecko_bindings::structs::{};", ty)); structs_types.insert(ty); // TODO this is hacky, figure out a better way to do it without @@ -504,10 +508,14 @@ mod bindings { .handle_table_items("array-types", |builder, item| { let cpp_type = item["cpp-type"].as_str().unwrap(); let rust_type = item["rust-type"].as_str().unwrap(); - builder - .raw_line(format!(concat!("pub type nsTArrayBorrowed_{}<'a> = ", - "&'a mut ::gecko_bindings::structs::nsTArray<{}>;"), - cpp_type, rust_type)) + builder.raw_line(format!( + concat!( + "pub type nsTArrayBorrowed_{}<'a> = ", + "&'a mut ::gecko_bindings::structs::nsTArray<{}>;" + ), + cpp_type, + rust_type + )) }) .handle_str_items("servo-immutable-borrow-types", |b, ty| b.borrowed_type(ty)) // Right now the only immutable borrow types are ones which we import @@ -529,7 +537,8 @@ mod bindings { .raw_line(format!( "pub type {0}Strong = ::gecko_bindings::sugar::ownership::Strong<{0}>;", ty - )).borrowed_type(ty) + )) + .borrowed_type(ty) .zero_size_type(ty, &structs_types); } for ty in get_boxed_types().iter() { @@ -538,14 +547,16 @@ mod bindings { .raw_line(format!( "pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;", ty - )).blacklist_type(format!("{}OwnedOrNull", ty)) + )) + .blacklist_type(format!("{}OwnedOrNull", ty)) .raw_line(format!( concat!( "pub type {0}OwnedOrNull = ", "::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;" ), ty - )).mutable_borrowed_type(ty) + )) + .mutable_borrowed_type(ty) .zero_size_type(ty, &structs_types); } write_binding_file(builder, BINDINGS_FILE, &fixups); @@ -595,9 +606,9 @@ mod bindings { #[cfg(not(feature = "bindgen"))] mod bindings { - use std::{env, fs, io}; - use std::path::{Path, PathBuf}; use super::common::*; + use std::path::{Path, PathBuf}; + use std::{env, fs, io}; /// Copy contents of one directory into another. /// It currently only does a shallow copy. @@ -622,7 +633,8 @@ mod bindings { println!("cargo:rerun-if-changed={}", dir.display()); copy_dir(&dir, &*OUTDIR_PATH, |path| { println!("cargo:rerun-if-changed={}", path.display()); - }).expect("Fail to copy generated files to out dir"); + }) + .expect("Fail to copy generated files to out dir"); } } diff --git a/servo/components/style/context.rs b/servo/components/style/context.rs index 0623cb05a4a1..822107a351dc 100644 --- a/servo/components/style/context.rs +++ b/servo/components/style/context.rs @@ -9,9 +9,9 @@ use animation::Animation; use app_units::Au; use bloom::StyleBloom; use data::{EagerPseudoStyles, ElementData}; -use dom::{SendElement, TElement}; #[cfg(feature = "servo")] use dom::OpaqueNode; +use dom::{SendElement, TElement}; use euclid::Size2D; use euclid::TypedScale; use font_metrics::FontMetricsProvider; @@ -27,8 +27,8 @@ use properties::PropertyId; use rule_cache::RuleCache; use rule_tree::StrongRuleNode; use selector_parser::{SnapshotMap, EAGER_PSEUDO_COUNT}; -use selectors::NthIndexCache; use selectors::matching::ElementSelectorFlags; +use selectors::NthIndexCache; use servo_arc::Arc; #[cfg(feature = "servo")] use servo_atoms::Atom; diff --git a/servo/components/style/counter_style/mod.rs b/servo/components/style/counter_style/mod.rs index 653d199545c6..73bab7659203 100644 --- a/servo/components/style/counter_style/mod.rs +++ b/servo/components/style/counter_style/mod.rs @@ -6,7 +6,6 @@ //! //! [counter-style]: https://drafts.csswg.org/css-counter-styles/ -use Atom; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser}; use cssparser::{CowRcStr, Parser, SourceLocation, Token}; use error_reporting::ContextualParseError; @@ -20,8 +19,9 @@ use std::ops::Range; use str::CssStringWriter; use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError}; use style_traits::{StyleParseErrorKind, ToCss}; -use values::CustomIdent; use values::specified::Integer; +use values::CustomIdent; +use Atom; /// Parse a counter style name reference. /// @@ -502,7 +502,8 @@ impl Parse for Ranges { } } Ok(opt_start..opt_end) - }).map(Ranges) + }) + .map(Ranges) } } } diff --git a/servo/components/style/custom_properties.rs b/servo/components/style/custom_properties.rs index 574031453e54..630fb4ba116e 100644 --- a/servo/components/style/custom_properties.rs +++ b/servo/components/style/custom_properties.rs @@ -6,7 +6,6 @@ //! //! [custom]: https://drafts.csswg.org/css-variables/ -use Atom; use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType}; use hash::map::Entry; use precomputed_hash::PrecomputedHash; @@ -20,6 +19,7 @@ use std::cmp; use std::fmt::{self, Write}; use std::hash::Hash; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; +use Atom; /// The environment from which to get `env` function values. /// @@ -631,11 +631,8 @@ impl<'a> CustomPropertiesBuilder<'a> { // environment variable here, perform substitution here instead // of forcing a full traversal in `substitute_all` afterwards. let value = if !has_references && unparsed_value.references_environment { - let result = substitute_references_in_value( - unparsed_value, - &map, - &self.environment, - ); + let result = + substitute_references_in_value(unparsed_value, &map, &self.environment); match result { Ok(new_value) => Arc::new(new_value), Err(..) => { @@ -886,11 +883,7 @@ fn substitute_all(custom_properties_map: &mut CustomPropertiesMap, environment: // Now we have shown that this variable is not in a loop, and // all of its dependencies should have been resolved. We can // start substitution now. - let result = substitute_references_in_value( - &value, - &context.map, - &context.environment, - ); + let result = substitute_references_in_value(&value, &context.map, &context.environment); match result { Ok(computed_value) => { diff --git a/servo/components/style/dom.rs b/servo/components/style/dom.rs index 872a55a54b23..3d2b05de7dcb 100644 --- a/servo/components/style/dom.rs +++ b/servo/components/style/dom.rs @@ -7,7 +7,6 @@ #![allow(unsafe_code)] #![deny(missing_docs)] -use {Atom, LocalName, Namespace, WeakAtom}; use applicable_declarations::ApplicableDeclarationBlock; use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; #[cfg(feature = "gecko")] @@ -20,9 +19,9 @@ use font_metrics::FontMetricsProvider; use media_queries::Device; use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock}; use selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl}; -use selectors::Element as SelectorsElement; use selectors::matching::{ElementSelectorFlags, QuirksMode, VisitedHandlingMode}; use selectors::sink::Push; +use selectors::Element as SelectorsElement; use servo_arc::{Arc, ArcBorrow}; use shared_lock::Locked; use std::fmt; @@ -31,6 +30,7 @@ use std::hash::Hash; use std::ops::Deref; use stylist::CascadeData; use traversal_flags::TraversalFlags; +use {Atom, LocalName, Namespace, WeakAtom}; /// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed /// back into a non-opaque representation. The only safe operation that can be diff --git a/servo/components/style/dom_apis.rs b/servo/components/style/dom_apis.rs index b7a5fbd24c09..371c83e7238c 100644 --- a/servo/components/style/dom_apis.rs +++ b/servo/components/style/dom_apis.rs @@ -5,17 +5,17 @@ //! Generic implementations of some DOM APIs so they can be shared between Servo //! and Gecko. -use Atom; use context::QuirksMode; use dom::{TDocument, TElement, TNode, TShadowRoot}; use invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation}; use invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector}; -use selectors::{Element, NthIndexCache, SelectorList}; use selectors::attr::CaseSensitivity; use selectors::matching::{self, MatchingContext, MatchingMode}; use selectors::parser::{Combinator, Component, LocalName, SelectorImpl}; +use selectors::{Element, NthIndexCache, SelectorList}; use smallvec::SmallVec; use std::borrow::Borrow; +use Atom; /// pub fn element_matches( @@ -338,7 +338,10 @@ fn local_name_matches(element: E, local_name: &LocalName) -> bool where E: TElement, { - let LocalName { ref name, ref lower_name } = *local_name; + let LocalName { + ref name, + ref lower_name, + } = *local_name; if element.is_html_element_in_html_document() { element.local_name() == lower_name.borrow() } else { @@ -543,23 +546,15 @@ where let case_sensitivity = quirks_mode.classes_and_ids_case_sensitivity(); collect_all_elements::(root, results, |element| { element.has_class(class, case_sensitivity) && - matching::matches_selector_list( - selector_list, - &element, - matching_context, - ) + matching::matches_selector_list(selector_list, &element, matching_context) }); - } + }, SimpleFilter::LocalName(ref local_name) => { collect_all_elements::(root, results, |element| { local_name_matches(element, local_name) && - matching::matches_selector_list( - selector_list, - &element, - matching_context, - ) + matching::matches_selector_list(selector_list, &element, matching_context) }); - } + }, } Ok(()) diff --git a/servo/components/style/font_face.rs b/servo/components/style/font_face.rs index b207b0291bcd..d257aa53773c 100644 --- a/servo/components/style/font_face.rs +++ b/servo/components/style/font_face.rs @@ -6,10 +6,10 @@ //! //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule -use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; -use cssparser::{CowRcStr, SourceLocation}; #[cfg(feature = "gecko")] use cssparser::UnicodeRange; +use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; +use cssparser::{CowRcStr, SourceLocation}; use error_reporting::ContextualParseError; use parser::{Parse, ParserContext}; #[cfg(feature = "gecko")] @@ -18,17 +18,17 @@ use selectors::parser::SelectorParseErrorKind; use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; use str::CssStringWriter; +use style_traits::values::SequenceWriter; use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError}; use style_traits::{StyleParseErrorKind, ToCss}; -use style_traits::values::SequenceWriter; use values::computed::font::FamilyName; use values::generics::font::FontStyle as GenericFontStyle; -use values::specified::Angle; +use values::specified::font::SpecifiedFontStyle; use values::specified::font::{AbsoluteFontWeight, FontStretch}; #[cfg(feature = "gecko")] use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings}; -use values::specified::font::SpecifiedFontStyle; use values::specified::url::SpecifiedUrl; +use values::specified::Angle; /// A source for a font-face rule. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] @@ -55,7 +55,10 @@ impl OneOrMoreSeparated for Source { pub enum FontFaceSourceListComponent { Url(*const ::gecko_bindings::structs::mozilla::css::URLValue), Local(*mut ::gecko_bindings::structs::nsAtom), - FormatHint { length: usize, utf8_bytes: *const u8 }, + FormatHint { + length: usize, + utf8_bytes: *const u8, + }, } /// A `UrlSource` represents a font-face source that has been specified with a @@ -133,7 +136,7 @@ macro_rules! impl_range { Ok(()) } } - } + }; } /// The font-weight descriptor: @@ -192,10 +195,7 @@ impl FontStretchRange { } } - let (min, max) = sort_range( - compute_stretch(&self.0), - compute_stretch(&self.1), - ); + let (min, max) = sort_range(compute_stretch(&self.0), compute_stretch(&self.1)); ComputedFontStretchRange(min, max) } } @@ -277,7 +277,7 @@ impl FontStyle { SpecifiedFontStyle::compute_angle_degrees(second), ); ComputedFontStyleDescriptor::Oblique(min, max) - } + }, } } } @@ -340,7 +340,8 @@ impl<'a> FontFace<'a> { } else { true } - }).cloned() + }) + .cloned() .collect(), ) } diff --git a/servo/components/style/font_metrics.rs b/servo/components/style/font_metrics.rs index dfe461cb3930..e093f13ef185 100644 --- a/servo/components/style/font_metrics.rs +++ b/servo/components/style/font_metrics.rs @@ -6,12 +6,12 @@ #![deny(missing_docs)] -use Atom; use app_units::Au; use context::SharedStyleContext; use logical_geometry::WritingMode; use media_queries::Device; use properties::style_structs::Font; +use Atom; /// 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/arc_types.rs b/servo/components/style/gecko/arc_types.rs index ad0b907e7a1f..ac1175743bcd 100644 --- a/servo/components/style/gecko/arc_types.rs +++ b/servo/components/style/gecko/arc_types.rs @@ -32,16 +32,16 @@ use gecko_bindings::structs::RawServoStyleRule; use gecko_bindings::structs::RawServoStyleSheetContents; use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong}; use media_queries::MediaList; -use properties::{ComputedValues, PropertyDeclarationBlock}; use properties::animated_properties::AnimationValue; +use properties::{ComputedValues, PropertyDeclarationBlock}; use rule_tree::StrongRuleNode; use servo_arc::{Arc, ArcBorrow}; use shared_lock::Locked; use std::{mem, ptr}; +use stylesheets::keyframes_rule::Keyframe; use stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule}; use stylesheets::{DocumentRule, ImportRule, KeyframesRule, MediaRule, NamespaceRule, PageRule}; use stylesheets::{StyleRule, StylesheetContents, SupportsRule}; -use stylesheets::keyframes_rule::Keyframe; use values::computed::QuotePair; macro_rules! impl_arc_ffi { diff --git a/servo/components/style/gecko/conversions.rs b/servo/components/style/gecko/conversions.rs index eeb13fce732d..b85b3bd6eb1a 100644 --- a/servo/components/style/gecko/conversions.rs +++ b/servo/components/style/gecko/conversions.rs @@ -12,15 +12,17 @@ use app_units::Au; use gecko::values::GeckoStyleCoordConvertible; use gecko_bindings::bindings; use gecko_bindings::structs::{self, nsStyleCoord_CalcValue}; -use gecko_bindings::structs::{nsresult, SheetType, nsStyleImage}; +use gecko_bindings::structs::{nsStyleImage, nsresult, SheetType}; use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue}; use std::f32::consts::PI; use stylesheets::{Origin, RulesMutateError}; -use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image}; -use values::computed::{Integer, LengthOrPercentage, LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto}; -use values::computed::{Percentage, TextAlign}; use values::computed::image::LineDirection; use values::computed::url::ComputedImageUrl; +use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image}; +use values::computed::{ + Integer, LengthOrPercentage, LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto, +}; +use values::computed::{Percentage, TextAlign}; use values::generics::box_::VerticalAlign; use values::generics::grid::{TrackListValue, TrackSize}; use values::generics::image::{CompatMode, GradientItem, Image as GenericImage}; @@ -113,13 +115,15 @@ impl From for NonNegativeLengthOrPercentageOrAuto { use style_traits::values::specified::AllowedNumericType; use values::generics::NonNegative; NonNegative(if other.mLength < 0 || other.mPercent < 0. { - LengthOrPercentageOrAuto::Calc( - CalcLengthOrPercentage::with_clamping_mode( - Au(other.mLength).into(), - if other.mHasPercent { Some(Percentage(other.mPercent)) } else { None }, - AllowedNumericType::NonNegative, - ) - ) + LengthOrPercentageOrAuto::Calc(CalcLengthOrPercentage::with_clamping_mode( + Au(other.mLength).into(), + if other.mHasPercent { + Some(Percentage(other.mPercent)) + } else { + None + }, + AllowedNumericType::NonNegative, + )) } else { other.into() }) @@ -231,11 +235,11 @@ impl nsStyleImage { // FIXME(emilio): This is really complex, we should use cbindgen for this. fn set_gradient(&mut self, gradient: Gradient) { + use self::structs::nsStyleCoord; use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_CORNER as CLOSEST_CORNER; use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE; - use self::structs::nsStyleCoord; use values::generics::image::{Circle, Ellipse, EndingShape, GradientKind, ShapeExtent}; use values::specified::position::{X, Y}; @@ -493,9 +497,9 @@ impl nsStyleImage { use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE; - use values::computed::Length; use values::computed::image::LineDirection; use values::computed::position::Position; + use values::computed::Length; use values::generics::image::{Circle, ColorStop, CompatMode, Ellipse}; use values::generics::image::{EndingShape, GradientKind, ShapeExtent}; @@ -625,7 +629,8 @@ impl nsStyleImage { position: LengthOrPercentage::from_gecko_style_coord(&stop.mLocation), }) } - }).collect(); + }) + .collect(); let compat_mode = if gecko_gradient.mMozLegacySyntax { CompatMode::Moz @@ -649,9 +654,9 @@ pub mod basic_shape { use gecko::values::GeckoStyleCoordConvertible; use gecko_bindings::structs; + use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners}; use gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType}; use gecko_bindings::structs::{StyleGeometryBox, StyleShapeSource, StyleShapeSourceType}; - use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners}; use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue}; use gecko_bindings::sugar::refptr::RefPtr; use std::borrow::Borrow; @@ -718,7 +723,8 @@ pub mod basic_shape { match other.mType { StyleShapeSourceType::URL => unsafe { let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr; - let other_url = RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref() as *mut _); + let other_url = + RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref() as *mut _); let url = ComputedUrl::from_url_value(other_url); ShapeSource::ImageOrUrl(url) }, diff --git a/servo/components/style/gecko/data.rs b/servo/components/style/gecko/data.rs index 2ede2f5b81f5..7761d9c26555 100644 --- a/servo/components/style/gecko/data.rs +++ b/servo/components/style/gecko/data.rs @@ -8,8 +8,10 @@ use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use context::QuirksMode; use dom::TElement; use gecko_bindings::bindings::{self, RawServoStyleSet}; -use gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes, StyleSheet as DomStyleSheet}; -use gecko_bindings::structs::{StyleSheetInfo, nsIDocument}; +use gecko_bindings::structs::{nsIDocument, StyleSheetInfo}; +use gecko_bindings::structs::{ + RawGeckoPresContextBorrowed, ServoStyleSetSizes, StyleSheet as DomStyleSheet, +}; use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; use invalidation::media_queries::{MediaListKey, ToMediaListKey}; use malloc_size_of::MallocSizeOfOps; diff --git a/servo/components/style/gecko/global_style_data.rs b/servo/components/style/gecko/global_style_data.rs index 6671de9867d2..8007acb6ce2a 100644 --- a/servo/components/style/gecko/global_style_data.rs +++ b/servo/components/style/gecko/global_style_data.rs @@ -5,8 +5,8 @@ //! Global style data use context::StyleSystemOptions; -use gecko_bindings::bindings::{Gecko_RegisterProfilerThread, Gecko_UnregisterProfilerThread}; use gecko_bindings::bindings::Gecko_SetJemallocThreadLocalArena; +use gecko_bindings::bindings::{Gecko_RegisterProfilerThread, Gecko_UnregisterProfilerThread}; use num_cpus; use parallel::STYLE_THREAD_STACK_SIZE_KB; use rayon; diff --git a/servo/components/style/gecko/media_features.rs b/servo/components/style/gecko/media_features.rs index e6f08c60f0cb..176d36459dfd 100644 --- a/servo/components/style/gecko/media_features.rs +++ b/servo/components/style/gecko/media_features.rs @@ -4,17 +4,17 @@ //! Gecko's media feature list and evaluator. -use Atom; use app_units::Au; use euclid::Size2D; use gecko_bindings::bindings; use gecko_bindings::structs; -use media_queries::Device; use media_queries::media_feature::{AllowsRanges, ParsingRequirements}; -use media_queries::media_feature::{MediaFeatureDescription, Evaluator}; +use media_queries::media_feature::{Evaluator, MediaFeatureDescription}; use media_queries::media_feature_expression::{AspectRatio, RangeOrOperator}; +use media_queries::Device; use values::computed::CSSPixelLength; use values::computed::Resolution; +use Atom; fn viewport_size(device: &Device) -> Size2D { let pc = device.pres_context(); @@ -305,15 +305,15 @@ bitflags! { } fn primary_pointer_capabilities(device: &Device) -> PointerCapabilities { - PointerCapabilities::from_bits_truncate( - unsafe { bindings::Gecko_MediaFeatures_PrimaryPointerCapabilities(device.document()) } - ) + PointerCapabilities::from_bits_truncate(unsafe { + bindings::Gecko_MediaFeatures_PrimaryPointerCapabilities(device.document()) + }) } fn all_pointer_capabilities(device: &Device) -> PointerCapabilities { - PointerCapabilities::from_bits_truncate( - unsafe { bindings::Gecko_MediaFeatures_AllPointerCapabilities(device.document()) } - ) + PointerCapabilities::from_bits_truncate(unsafe { + bindings::Gecko_MediaFeatures_AllPointerCapabilities(device.document()) + }) } #[derive(Clone, Copy, Debug, FromPrimitive, Parse, ToCss)] diff --git a/servo/components/style/gecko/media_queries.rs b/servo/components/style/gecko/media_queries.rs index ae14d332f89a..25abac6f974c 100644 --- a/servo/components/style/gecko/media_queries.rs +++ b/servo/components/style/gecko/media_queries.rs @@ -4,8 +4,8 @@ //! Gecko's media-query device and expression representation. -use app_units::AU_PER_PX; use app_units::Au; +use app_units::AU_PER_PX; use cssparser::RGBA; use custom_properties::CssEnvironment; use euclid::Size2D; @@ -20,10 +20,10 @@ use servo_arc::Arc; use std::fmt; use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering}; use string_cache::Atom; -use style_traits::{CSSPixel, DevicePixel}; use style_traits::viewport::ViewportConstraints; -use values::{CustomIdent, KeyframesName}; +use style_traits::{CSSPixel, DevicePixel}; use values::computed::font::FontSize; +use values::{CustomIdent, KeyframesName}; /// The `Device` in Gecko wraps a pres context, has a default values computed, /// and contains all the viewport rule state. diff --git a/servo/components/style/gecko/non_ts_pseudo_class_list.rs b/servo/components/style/gecko/non_ts_pseudo_class_list.rs index 813250e43839..b37af9d71b6a 100644 --- a/servo/components/style/gecko/non_ts_pseudo_class_list.rs +++ b/servo/components/style/gecko/non_ts_pseudo_class_list.rs @@ -3,29 +3,29 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* - * This file contains a helper macro includes all supported non-tree-structural - * pseudo-classes. - * +* This file contains a helper macro includes all supported non-tree-structural +* pseudo-classes. +* - * FIXME: Find a way to autogenerate this file. - * - * Expected usage is as follows: - * ``` - * macro_rules! pseudo_class_macro{ - * ([$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*]) => { - * // do stuff - * } - * } - * apply_non_ts_list!(pseudo_class_macro) - * ``` - * - * $gecko_type can be either "_" or an ident in Gecko's CSSPseudoClassType. - * $state can be either "_" or an expression of type ElementState. If present, - * the semantics are that the pseudo-class matches if any of the bits in - * $state are set on the element. - * $flags can be either "_" or an expression of type NonTSPseudoClassFlag, - * see selector_parser.rs for more details. - */ +* FIXME: Find a way to autogenerate this file. +* +* Expected usage is as follows: +* ``` +* macro_rules! pseudo_class_macro{ +* ([$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*]) => { +* // do stuff +* } +* } +* apply_non_ts_list!(pseudo_class_macro) +* ``` +* +* $gecko_type can be either "_" or an ident in Gecko's CSSPseudoClassType. +* $state can be either "_" or an expression of type ElementState. If present, +* the semantics are that the pseudo-class matches if any of the bits in +* $state are set on the element. +* $flags can be either "_" or an expression of type NonTSPseudoClassFlag, +* see selector_parser.rs for more details. +*/ macro_rules! apply_non_ts_list { ($apply_macro:ident) => { diff --git a/servo/components/style/gecko/pseudo_element.rs b/servo/components/style/gecko/pseudo_element.rs index 1164a39bdc42..b17a5e6349e1 100644 --- a/servo/components/style/gecko/pseudo_element.rs +++ b/servo/components/style/gecko/pseudo_element.rs @@ -10,8 +10,8 @@ use cssparser::ToCss; use gecko_bindings::structs::{self, CSSPseudoElementType}; -use properties::{ComputedValues, PropertyFlags}; use properties::longhands::display::computed_value::T as Display; +use properties::{ComputedValues, PropertyFlags}; use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl}; use std::fmt; use str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase}; diff --git a/servo/components/style/gecko/selector_parser.rs b/servo/components/style/gecko/selector_parser.rs index 2365356f2f8b..420c2f014363 100644 --- a/servo/components/style/gecko/selector_parser.rs +++ b/servo/components/style/gecko/selector_parser.rs @@ -12,10 +12,10 @@ use gecko_bindings::structs::RawServoSelectorList; use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use invalidation::element::document_state::InvalidationMatchingData; use selector_parser::{Direction, SelectorParser}; -use selectors::SelectorList; -use selectors::parser::{SelectorParseErrorKind, Visit}; use selectors::parser::{self as selector_parser, Selector}; +use selectors::parser::{SelectorParseErrorKind, Visit}; use selectors::visitor::SelectorVisitor; +use selectors::SelectorList; use std::fmt; use str::starts_with_ignore_ascii_case; use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; diff --git a/servo/components/style/gecko/snapshot.rs b/servo/components/style/gecko/snapshot.rs index fc4a9121ae40..a72fea248aa6 100644 --- a/servo/components/style/gecko/snapshot.rs +++ b/servo/components/style/gecko/snapshot.rs @@ -5,7 +5,6 @@ //! A gecko snapshot, that stores the element attributes and state before they //! change in order to properly calculate restyle hints. -use WeakAtom; use dom::TElement; use element_state::ElementState; use gecko::snapshot_helpers; @@ -18,6 +17,7 @@ use invalidation::element::element_wrapper::ElementSnapshot; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator}; use selectors::attr::{CaseSensitivity, NamespaceConstraint}; use string_cache::{Atom, Namespace}; +use WeakAtom; /// A snapshot of a Gecko element. pub type GeckoElementSnapshot = ServoElementSnapshot; diff --git a/servo/components/style/gecko/snapshot_helpers.rs b/servo/components/style/gecko/snapshot_helpers.rs index 371a2b78da16..61f6646514d3 100644 --- a/servo/components/style/gecko/snapshot_helpers.rs +++ b/servo/components/style/gecko/snapshot_helpers.rs @@ -4,11 +4,11 @@ //! Element an snapshot common logic. -use CaseSensitivityExt; use gecko_bindings::bindings; use gecko_bindings::structs::{self, nsAtom}; use selectors::attr::CaseSensitivity; use string_cache::{Atom, WeakAtom}; +use CaseSensitivityExt; /// A function that, given an element of type `T`, allows you to get a single /// class or a class list. diff --git a/servo/components/style/gecko/url.rs b/servo/components/style/gecko/url.rs index 64ea654ba0cd..a04b8e57b70d 100644 --- a/servo/components/style/gecko/url.rs +++ b/servo/components/style/gecko/url.rs @@ -6,10 +6,10 @@ use cssparser::Parser; use gecko_bindings::bindings; -use gecko_bindings::structs::root::mozilla::CORSMode; use gecko_bindings::structs::root::mozilla::css::URLValue; +use gecko_bindings::structs::root::mozilla::CORSMode; use gecko_bindings::structs::root::nsStyleImageRequest; -use gecko_bindings::sugar::ownership::{HasArcFFI, FFIArcHelpers}; +use gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI}; use gecko_bindings::sugar::refptr::RefPtr; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use nsstring::nsCString; @@ -123,10 +123,7 @@ impl SpecifiedUrl { fn from_css_url_with_cors(url: CssUrl, cors: CORSMode) -> Self { let url_value = unsafe { - let ptr = bindings::Gecko_URLValue_Create( - url.0.clone().into_strong(), - cors, - ); + let ptr = bindings::Gecko_URLValue_Create(url.0.clone().into_strong(), cors); // We do not expect Gecko_URLValue_Create returns null. debug_assert!(!ptr.is_null()); RefPtr::from_addrefed(ptr) @@ -261,11 +258,7 @@ impl ToCss for ComputedUrl { where W: Write, { - serialize_computed_url( - &self.0.url_value, - dest, - bindings::Gecko_GetComputedURLSpec, - ) + serialize_computed_url(&self.0.url_value, dest, bindings::Gecko_GetComputedURLSpec) } } diff --git a/servo/components/style/gecko/values.rs b/servo/components/style/gecko/values.rs index 4b9824048095..9020888d9a8d 100644 --- a/servo/components/style/gecko/values.rs +++ b/servo/components/style/gecko/values.rs @@ -6,30 +6,34 @@ //! Different kind of helpers to interact with Gecko values. -use Atom; use app_units::Au; use counter_style::{Symbol, Symbols}; use cssparser::RGBA; -use gecko_bindings::structs::{self, CounterStylePtr, nsStyleCoord}; +use gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr}; use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius}; use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue}; use media_queries::Device; use nsstring::{nsACString, nsCStr}; use std::cmp::max; -use values::{Auto, Either, None_, Normal}; -use values::computed::{Angle, ExtremumLength, Length, LengthOrPercentage, LengthOrPercentageOrAuto}; -use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage}; -use values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength, Percentage}; -use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber}; -use values::computed::FlexBasis as ComputedFlexBasis; use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius; -use values::generics::{CounterStyleOrNone, NonNegative}; +use values::computed::FlexBasis as ComputedFlexBasis; +use values::computed::{ + Angle, ExtremumLength, Length, LengthOrPercentage, LengthOrPercentageOrAuto, +}; +use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage}; +use values::computed::{ + MaxLength as ComputedMaxLength, MozLength as ComputedMozLength, Percentage, +}; +use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber}; use values::generics::basic_shape::ShapeRadius; use values::generics::box_::Perspective; use values::generics::flex::FlexBasis; use values::generics::gecko::ScrollSnapPoint; use values::generics::grid::{TrackBreadth, TrackKeyword}; use values::generics::length::{MaxLength, MozLength}; +use values::generics::{CounterStyleOrNone, NonNegative}; +use values::{Auto, Either, None_, Normal}; +use Atom; /// A trait that defines an interface to convert from and to `nsStyleCoord`s. pub trait GeckoStyleCoordConvertible: Sized { @@ -537,7 +541,8 @@ impl CounterStyleOrNone { .map(|symbol| match *symbol { Symbol::String(ref s) => nsCStr::from(s), Symbol::Ident(_) => unreachable!("Should not have identifier in symbols()"), - }).collect(); + }) + .collect(); let symbols: Vec<_> = symbols .iter() .map(|symbol| symbol as &nsACString as *const _) @@ -557,8 +562,8 @@ impl CounterStyleOrNone { /// Convert Gecko CounterStylePtr to CounterStyleOrNone or String. pub fn from_gecko_value(gecko_value: &CounterStylePtr) -> Either { use gecko_bindings::bindings; - use values::CustomIdent; use values::generics::SymbolsType; + use values::CustomIdent; let name = unsafe { bindings::Gecko_CounterStyle_GetName(gecko_value) }; if !name.is_null() { diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index efe37e647c5e..b67e69849d17 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -14,7 +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 CaseSensitivityExt; use app_units::Au; use applicable_declarations::ApplicableDeclarationBlock; use atomic_refcell::{AtomicRefCell, AtomicRefMut}; @@ -29,9 +28,6 @@ use gecko::global_style_data::GLOBAL_STYLE_DATA; use gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl}; use gecko::snapshot_helpers; use gecko_bindings::bindings; -use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme}; -use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetPreviousSibling, Gecko_GetNextStyleChild}; -use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use gecko_bindings::bindings::Gecko_ElementHasAnimations; use gecko_bindings::bindings::Gecko_ElementHasCSSAnimations; use gecko_bindings::bindings::Gecko_ElementHasCSSTransitions; @@ -47,35 +43,40 @@ use gecko_bindings::bindings::Gecko_IsSignificantChild; use gecko_bindings::bindings::Gecko_MatchLang; use gecko_bindings::bindings::Gecko_UnsetDirtyStyleAttr; use gecko_bindings::bindings::Gecko_UpdateAnimations; +use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme}; +use gecko_bindings::bindings::{ + Gecko_GetLastChild, Gecko_GetNextStyleChild, Gecko_GetPreviousSibling, +}; +use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use gecko_bindings::structs; -use gecko_bindings::structs::{RawGeckoElement, RawGeckoNode, RawGeckoXBLBinding}; -use gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag}; +use gecko_bindings::structs::nsChangeHint; +use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme; +use gecko_bindings::structs::nsRestyleHint; +use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel; use gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT; use gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO; use gecko_bindings::structs::ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO; use gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT; -use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel; use gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES; use gecko_bindings::structs::NODE_NEEDS_FRAME; -use gecko_bindings::structs::nsChangeHint; -use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme; -use gecko_bindings::structs::nsRestyleHint; +use gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag}; +use gecko_bindings::structs::{RawGeckoElement, RawGeckoNode, RawGeckoXBLBinding}; use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI}; use hash::FxHashMap; use logical_geometry::WritingMode; use media_queries::Device; -use properties::{ComputedValues, LonghandId}; -use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock}; use properties::animated_properties::{AnimationValue, AnimationValueMap}; use properties::style_structs::Font; +use properties::{ComputedValues, LonghandId}; +use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock}; use rule_tree::CascadeLevel as ServoCascadeLevel; use selector_parser::{AttrValue, HorizontalDirection, Lang}; -use selectors::{Element, OpaqueElement}; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator}; use selectors::attr::{CaseSensitivity, NamespaceConstraint}; -use selectors::matching::{ElementSelectorFlags, MatchingContext}; use selectors::matching::VisitedHandlingMode; +use selectors::matching::{ElementSelectorFlags, MatchingContext}; use selectors::sink::Push; +use selectors::{Element, OpaqueElement}; use servo_arc::{Arc, ArcBorrow, RawOffsetArc}; use shared_lock::Locked; use std::cell::RefCell; @@ -85,6 +86,7 @@ use std::mem; use std::ptr; use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; use stylist::CascadeData; +use CaseSensitivityExt; #[inline] fn elements_with_id<'a, 'le>( @@ -937,7 +939,8 @@ impl<'le> GeckoElement<'le> { .animate( to.as_ref().unwrap(), Procedure::Interpolate { progress: 0.5 }, - ).is_ok() + ) + .is_ok() } } @@ -1278,7 +1281,8 @@ impl<'le> TElement for GeckoElement<'le> { Some( Locked::::as_arc( &*(&raw as *const &structs::RawServoDeclarationBlock), - ).borrow_arc(), + ) + .borrow_arc(), ) } } diff --git a/servo/components/style/gecko_bindings/sugar/ns_css_shadow_array.rs b/servo/components/style/gecko_bindings/sugar/ns_css_shadow_array.rs index 8e445a837e62..f0050796c22c 100644 --- a/servo/components/style/gecko_bindings/sugar/ns_css_shadow_array.rs +++ b/servo/components/style/gecko_bindings/sugar/ns_css_shadow_array.rs @@ -7,9 +7,9 @@ use gecko_bindings::bindings::Gecko_AddRefCSSShadowArrayArbitraryThread; use gecko_bindings::bindings::Gecko_NewCSSShadowArray; use gecko_bindings::bindings::Gecko_ReleaseCSSShadowArrayArbitraryThread; -use gecko_bindings::structs::{RefPtr, nsCSSShadowArray, nsCSSShadowItem}; -use std::{ptr, slice}; +use gecko_bindings::structs::{nsCSSShadowArray, nsCSSShadowItem, RefPtr}; use std::ops::{Deref, DerefMut}; +use std::{ptr, slice}; impl RefPtr { /// Replaces the current `nsCSSShadowArray` with a new one of len `len`. diff --git a/servo/components/style/gecko_bindings/sugar/ns_css_value.rs b/servo/components/style/gecko_bindings/sugar/ns_css_value.rs index f41150712b3a..a40671eb598f 100644 --- a/servo/components/style/gecko_bindings/sugar/ns_css_value.rs +++ b/servo/components/style/gecko_bindings/sugar/ns_css_value.rs @@ -234,9 +234,13 @@ impl nsCSSValue { } debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_List); let list: &mut structs::nsCSSValueList = &mut unsafe { - self.mValue.mList.as_ref() // &*nsCSSValueList_heap - .as_mut().expect("List pointer should be non-null") - }._base; + self.mValue + .mList + .as_ref() // &*nsCSSValueList_heap + .as_mut() + .expect("List pointer should be non-null") + } + ._base; for (item, new_value) in list.into_iter().zip(values) { *item = new_value; } @@ -255,9 +259,13 @@ impl nsCSSValue { } debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_PairList); let mut item_ptr = &mut unsafe { - self.mValue.mPairList.as_ref() // &*nsCSSValuePairList_heap - .as_mut().expect("List pointer should be non-null") - }._base as *mut structs::nsCSSValuePairList; + self.mValue + .mPairList + .as_ref() // &*nsCSSValuePairList_heap + .as_mut() + .expect("List pointer should be non-null") + } + ._base as *mut structs::nsCSSValuePairList; while let Some(item) = unsafe { item_ptr.as_mut() } { let value = values.next().expect("Values shouldn't have been exhausted"); item.mXValue = value.0; diff --git a/servo/components/style/gecko_bindings/sugar/ns_style_auto_array.rs b/servo/components/style/gecko_bindings/sugar/ns_style_auto_array.rs index 8adb8bb54d17..256199df7276 100644 --- a/servo/components/style/gecko_bindings/sugar/ns_style_auto_array.rs +++ b/servo/components/style/gecko_bindings/sugar/ns_style_auto_array.rs @@ -6,8 +6,8 @@ use gecko_bindings::bindings::Gecko_EnsureStyleAnimationArrayLength; use gecko_bindings::bindings::Gecko_EnsureStyleTransitionArrayLength; -use gecko_bindings::structs::{StyleAnimation, StyleTransition}; use gecko_bindings::structs::nsStyleAutoArray; +use gecko_bindings::structs::{StyleAnimation, StyleTransition}; use std::iter::{once, Chain, IntoIterator, Once}; use std::ops::{Index, IndexMut}; use std::slice::{Iter, IterMut}; diff --git a/servo/components/style/gecko_bindings/sugar/ns_style_coord.rs b/servo/components/style/gecko_bindings/sugar/ns_style_coord.rs index a4220f8c53c0..4dca851f0509 100644 --- a/servo/components/style/gecko_bindings/sugar/ns_style_coord.rs +++ b/servo/components/style/gecko_bindings/sugar/ns_style_coord.rs @@ -6,7 +6,7 @@ use gecko_bindings::bindings; use gecko_bindings::structs::{nsStyleCoord, nsStyleCoord_Calc, nsStyleCoord_CalcValue}; -use gecko_bindings::structs::{nscoord, nsStyleCorners, nsStyleSides, nsStyleUnion, nsStyleUnit}; +use gecko_bindings::structs::{nsStyleCorners, nsStyleSides, nsStyleUnion, nsStyleUnit, nscoord}; use std::mem; impl nsStyleCoord { @@ -277,8 +277,8 @@ pub unsafe trait CoordDataMut: CoordData { #[inline(always)] /// Sets the inner value. fn set_value(&mut self, value: CoordDataValue) { - use gecko_bindings::structs::nsStyleUnit::*; use self::CoordDataValue::*; + use gecko_bindings::structs::nsStyleUnit::*; self.reset(); unsafe { let (unit, union) = self.values_mut(); @@ -364,8 +364,8 @@ pub unsafe trait CoordData { #[inline(always)] /// Get the appropriate value for this object. fn as_value(&self) -> CoordDataValue { - use gecko_bindings::structs::nsStyleUnit::*; use self::CoordDataValue::*; + use gecko_bindings::structs::nsStyleUnit::*; unsafe { match self.unit() { eStyleUnit_Null => Null, diff --git a/servo/components/style/gecko_bindings/sugar/ns_t_array.rs b/servo/components/style/gecko_bindings/sugar/ns_t_array.rs index 72a7481fe968..dba867c66fe5 100644 --- a/servo/components/style/gecko_bindings/sugar/ns_t_array.rs +++ b/servo/components/style/gecko_bindings/sugar/ns_t_array.rs @@ -117,7 +117,9 @@ impl nsTArray { I: ExactSizeIterator + Iterator, { debug_assert!(iter.len() <= 0xFFFFFFFF); - unsafe { self.set_len_pod(iter.len() as u32); } + unsafe { + self.set_len_pod(iter.len() as u32); + } self.iter_mut().zip(iter).for_each(|(r, v)| *r = v); } } diff --git a/servo/components/style/gecko_bindings/sugar/refptr.rs b/servo/components/style/gecko_bindings/sugar/refptr.rs index 09bc19d41280..d387c6da0250 100644 --- a/servo/components/style/gecko_bindings/sugar/refptr.rs +++ b/servo/components/style/gecko_bindings/sugar/refptr.rs @@ -4,13 +4,13 @@ //! A rust helper to ease the use of Gecko's refcounted types. -use Atom; -use gecko_bindings::{structs, bindings}; use gecko_bindings::sugar::ownership::HasArcFFI; +use gecko_bindings::{bindings, structs}; use servo_arc::Arc; -use std::{fmt, mem, ptr}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; +use std::{fmt, mem, ptr}; +use Atom; /// Trait for all objects that have Addref() and Release /// methods and can be placed inside RefPtr @@ -217,7 +217,9 @@ impl structs::RefPtr { where U: HasArcFFI, { - unsafe { U::release_opt(self.mRawPtr.as_ref()); } + unsafe { + U::release_opt(self.mRawPtr.as_ref()); + } self.set_arc_leaky(other); } diff --git a/servo/components/style/gecko_bindings/sugar/style_complex_color.rs b/servo/components/style/gecko_bindings/sugar/style_complex_color.rs index c2b3b1c62709..e65d023a68d9 100644 --- a/servo/components/style/gecko_bindings/sugar/style_complex_color.rs +++ b/servo/components/style/gecko_bindings/sugar/style_complex_color.rs @@ -7,10 +7,10 @@ use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor}; use gecko_bindings::structs::StyleComplexColor; use gecko_bindings::structs::StyleComplexColor_Tag as Tag; -use values::{Auto, Either}; -use values::computed::{Color as ComputedColor, RGBAColor as ComputedRGBA}; use values::computed::ui::ColorOrAuto; +use values::computed::{Color as ComputedColor, RGBAColor as ComputedRGBA}; use values::generics::color::{Color as GenericColor, ComplexColorRatios}; +use values::{Auto, Either}; impl StyleComplexColor { /// Create a `StyleComplexColor` value that represents `currentColor`. diff --git a/servo/components/style/gecko_string_cache/mod.rs b/servo/components/style/gecko_string_cache/mod.rs index f4941184beb4..aedf065aaf40 100644 --- a/servo/components/style/gecko_string_cache/mod.rs +++ b/servo/components/style/gecko_string_cache/mod.rs @@ -17,13 +17,13 @@ use gecko_bindings::bindings::Gecko_ReleaseAtom; use gecko_bindings::structs::{nsAtom, nsAtom_AtomKind, nsDynamicAtom, nsStaticAtom}; use nsstring::{nsAString, nsStr}; use precomputed_hash::PrecomputedHash; -use std::{mem, slice, str}; use std::borrow::{Borrow, Cow}; use std::char::{self, DecodeUtf16}; use std::fmt::{self, Write}; use std::hash::{Hash, Hasher}; use std::iter::Cloned; use std::ops::Deref; +use std::{mem, slice, str}; use style_traits::SpecifiedValueInfo; #[macro_use] diff --git a/servo/components/style/invalidation/element/element_wrapper.rs b/servo/components/style/invalidation/element/element_wrapper.rs index cd1b1d13a256..457c8238abc1 100644 --- a/servo/components/style/invalidation/element/element_wrapper.rs +++ b/servo/components/style/invalidation/element/element_wrapper.rs @@ -5,16 +5,16 @@ //! A wrapper over an element and a snapshot, that allows us to selector-match //! against a past state of the element. -use {Atom, CaseSensitivityExt, LocalName, Namespace, WeakAtom}; use dom::TElement; use element_state::ElementState; use selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl}; use selector_parser::{Snapshot, SnapshotMap}; -use selectors::{Element, OpaqueElement}; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::matching::{ElementSelectorFlags, MatchingContext}; +use selectors::{Element, OpaqueElement}; use std::cell::Cell; use std::fmt; +use {Atom, CaseSensitivityExt, LocalName, Namespace, WeakAtom}; /// In order to compute restyle hints, we perform a selector match against a /// list of partial selectors whose rightmost simple selector may be sensitive diff --git a/servo/components/style/invalidation/element/invalidation_map.rs b/servo/components/style/invalidation/element/invalidation_map.rs index 038852a6dd4a..adc6783a2729 100644 --- a/servo/components/style/invalidation/element/invalidation_map.rs +++ b/servo/components/style/invalidation/element/invalidation_map.rs @@ -4,7 +4,6 @@ //! Code for invalidations due to state or attribute changes. -use {Atom, LocalName, Namespace}; use context::QuirksMode; use element_state::{DocumentState, ElementState}; use fallible::FallibleVec; @@ -16,6 +15,7 @@ use selectors::parser::{Combinator, Component}; use selectors::parser::{Selector, SelectorIter, Visit}; use selectors::visitor::SelectorVisitor; use smallvec::SmallVec; +use {Atom, LocalName, Namespace}; /// Mapping between (partial) CompoundSelectors (and the combinator to their /// right) and the states and attributes they depend on. diff --git a/servo/components/style/invalidation/element/invalidator.rs b/servo/components/style/invalidation/element/invalidator.rs index 8d60ade88e26..4a38c0ef931d 100644 --- a/servo/components/style/invalidation/element/invalidator.rs +++ b/servo/components/style/invalidation/element/invalidator.rs @@ -8,8 +8,8 @@ use context::StackLimitChecker; use dom::{TElement, TNode, TShadowRoot}; use selector_parser::SelectorImpl; -use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext}; use selectors::matching::matches_compound_selector_from; +use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext}; use selectors::parser::{Combinator, Component, Selector}; use smallvec::SmallVec; use std::fmt; diff --git a/servo/components/style/invalidation/element/state_and_attributes.rs b/servo/components/style/invalidation/element/state_and_attributes.rs index bf259bb6f025..1de675d396e7 100644 --- a/servo/components/style/invalidation/element/state_and_attributes.rs +++ b/servo/components/style/invalidation/element/state_and_attributes.rs @@ -5,7 +5,6 @@ //! An invalidation processor for style changes due to state and attribute //! changes. -use {Atom, WeakAtom}; use context::SharedStyleContext; use data::ElementData; use dom::TElement; @@ -17,12 +16,13 @@ use invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; use invalidation::element::restyle_hints::RestyleHint; use selector_map::SelectorMap; use selector_parser::Snapshot; -use selectors::NthIndexCache; use selectors::attr::CaseSensitivity; -use selectors::matching::{MatchingContext, MatchingMode, VisitedHandlingMode}; use selectors::matching::matches_selector; +use selectors::matching::{MatchingContext, MatchingMode, VisitedHandlingMode}; +use selectors::NthIndexCache; use smallvec::SmallVec; use stylesheets::origin::{Origin, OriginSet}; +use {Atom, WeakAtom}; /// The collector implementation. struct Collector<'a, 'b: 'a, 'selectors: 'a, E> diff --git a/servo/components/style/invalidation/stylesheets.rs b/servo/components/style/invalidation/stylesheets.rs index 1889d325630f..fac9428bc75f 100644 --- a/servo/components/style/invalidation/stylesheets.rs +++ b/servo/components/style/invalidation/stylesheets.rs @@ -7,9 +7,6 @@ #![deny(unsafe_code)] -use Atom; -use CaseSensitivityExt; -use LocalName as SelectorLocalName; use dom::{TDocument, TElement, TNode}; use fxhash::FxHashSet; use invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; @@ -20,6 +17,9 @@ use selectors::attr::CaseSensitivity; use selectors::parser::{Component, LocalName, Selector}; use shared_lock::SharedRwLockReadGuard; use stylesheets::{CssRule, StylesheetInDocument}; +use Atom; +use CaseSensitivityExt; +use LocalName as SelectorLocalName; /// A style sheet invalidation represents a kind of element or subtree that may /// need to be restyled. Whether it represents a whole subtree or just a single diff --git a/servo/components/style/lib.rs b/servo/components/style/lib.rs index 1f50e062545a..29df16f6183a 100644 --- a/servo/components/style/lib.rs +++ b/servo/components/style/lib.rs @@ -84,7 +84,8 @@ pub extern crate servo_arc; #[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms; -#[cfg(feature = "servo")] extern crate servo_channel; +#[cfg(feature = "servo")] +extern crate servo_channel; #[cfg(feature = "servo")] extern crate servo_config; #[cfg(feature = "servo")] @@ -168,20 +169,20 @@ pub use gecko_string_cache as string_cache; #[cfg(feature = "gecko")] pub use gecko_string_cache::Atom; #[cfg(feature = "gecko")] -pub use gecko_string_cache::Namespace; -#[cfg(feature = "gecko")] pub use gecko_string_cache::Atom as Prefix; #[cfg(feature = "gecko")] pub use gecko_string_cache::Atom as LocalName; +#[cfg(feature = "gecko")] +pub use gecko_string_cache::Namespace; -#[cfg(feature = "servo")] -pub use servo_atoms::Atom; -#[cfg(feature = "servo")] -pub use html5ever::Prefix; #[cfg(feature = "servo")] pub use html5ever::LocalName; #[cfg(feature = "servo")] pub use html5ever::Namespace; +#[cfg(feature = "servo")] +pub use html5ever::Prefix; +#[cfg(feature = "servo")] +pub use servo_atoms::Atom; /// The CSS properties supported by the style system. /// Generated from the properties.mako.rs template by build.rs diff --git a/servo/components/style/logical_geometry.rs b/servo/components/style/logical_geometry.rs index 8c677c210bfb..cae71229bbdd 100644 --- a/servo/components/style/logical_geometry.rs +++ b/servo/components/style/logical_geometry.rs @@ -4,8 +4,8 @@ //! Geometry in flow-relative space. -use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; use euclid::num::Zero; +use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; use properties::style_structs; use std::cmp::{max, min}; use std::fmt::{self, Debug, Error, Formatter}; diff --git a/servo/components/style/matching.rs b/servo/components/style/matching.rs index 9d840a5bbd93..1b0f14feb56b 100644 --- a/servo/components/style/matching.rs +++ b/servo/components/style/matching.rs @@ -12,8 +12,8 @@ use context::{SharedStyleContext, StyleContext}; use data::ElementData; use dom::TElement; use invalidation::element::restyle_hints::RestyleHint; -use properties::ComputedValues; use properties::longhands::display::computed_value::T as Display; +use properties::ComputedValues; use rule_tree::{CascadeLevel, StrongRuleNode}; use selector_parser::{PseudoElement, RestyleDamage}; use selectors::matching::ElementSelectorFlags; @@ -224,7 +224,8 @@ trait PrivateMatchMethods: TElement { context, RuleInclusion::All, PseudoElementResolution::IfApplicable, - ).cascade_style_and_visited_with_default_parents(inputs); + ) + .cascade_style_and_visited_with_default_parents(inputs); Some(style.0) } @@ -618,14 +619,12 @@ trait PrivateMatchMethods: TElement { match *running_animation { Animation::Transition(..) => unreachable!(), - Animation::Keyframes(_, _, _, ref mut state) => { - match update { - AnimationUpdate::Regular => {}, - AnimationUpdate::AnimationCanceled => { - state.expired = true; - } - } - } + Animation::Keyframes(_, _, _, ref mut state) => match update { + AnimationUpdate::Regular => {}, + AnimationUpdate::AnimationCanceled => { + state.expired = true; + }, + }, } } } diff --git a/servo/components/style/media_queries/media_condition.rs b/servo/components/style/media_queries/media_condition.rs index 78252db8c0b1..af2d5a3be69e 100644 --- a/servo/components/style/media_queries/media_condition.rs +++ b/servo/components/style/media_queries/media_condition.rs @@ -6,12 +6,12 @@ //! //! https://drafts.csswg.org/mediaqueries-4/#typedef-media-condition +use super::{Device, MediaFeatureExpression}; use context::QuirksMode; use cssparser::{Parser, Token}; use parser::ParserContext; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use super::{Device, MediaFeatureExpression}; /// A binary `and` or `or` operator. #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)] diff --git a/servo/components/style/media_queries/media_feature.rs b/servo/components/style/media_queries/media_feature.rs index 771a11e8fbbe..84a13c06f635 100644 --- a/servo/components/style/media_queries/media_feature.rs +++ b/servo/components/style/media_queries/media_feature.rs @@ -4,14 +4,14 @@ //! Media features. -use Atom; +use super::media_feature_expression::{AspectRatio, RangeOrOperator}; +use super::Device; use cssparser::Parser; use parser::ParserContext; use std::fmt; use style_traits::ParseError; -use super::Device; -use super::media_feature_expression::{AspectRatio, RangeOrOperator}; use values::computed::{CSSPixelLength, Resolution}; +use Atom; /// A generic discriminant for an enum value. pub type KeywordDiscriminant = u8; diff --git a/servo/components/style/media_queries/media_feature_expression.rs b/servo/components/style/media_queries/media_feature_expression.rs index 64406218e889..52292e9571b5 100644 --- a/servo/components/style/media_queries/media_feature_expression.rs +++ b/servo/components/style/media_queries/media_feature_expression.rs @@ -5,24 +5,24 @@ //! Parsing for media feature expressions, like `(foo: bar)` or //! `(width >= 400px)`. -use Atom; +use super::media_feature::{Evaluator, MediaFeatureDescription}; +use super::media_feature::{KeywordDiscriminant, ParsingRequirements}; +use super::Device; use context::QuirksMode; use cssparser::{Parser, Token}; #[cfg(feature = "gecko")] use gecko_bindings::structs; use num_traits::Zero; use parser::{Parse, ParserContext}; -use std::cmp::{PartialOrd, Ordering}; +use std::cmp::{Ordering, PartialOrd}; use std::fmt::{self, Write}; use str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use stylesheets::Origin; -use super::Device; -use super::media_feature::{Evaluator, MediaFeatureDescription}; -use super::media_feature::{ParsingRequirements, KeywordDiscriminant}; -use values::{serialize_atom_identifier, CSSFloat}; use values::computed::{self, ToComputedValue}; use values::specified::{Integer, Length, Number, Resolution}; +use values::{serialize_atom_identifier, CSSFloat}; +use Atom; /// An aspect ratio, with a numerator and denominator. #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)] diff --git a/servo/components/style/media_queries/media_list.rs b/servo/components/style/media_queries/media_list.rs index 168671288cfd..302b3db69990 100644 --- a/servo/components/style/media_queries/media_list.rs +++ b/servo/components/style/media_queries/media_list.rs @@ -6,12 +6,12 @@ //! //! https://drafts.csswg.org/mediaqueries/#typedef-media-query-list +use super::{Device, MediaQuery, Qualifier}; use context::QuirksMode; use cssparser::{Delimiter, Parser}; use cssparser::{ParserInput, Token}; use error_reporting::ContextualParseError; use parser::ParserContext; -use super::{Device, MediaQuery, Qualifier}; /// A type that encapsulates a media query list. #[css(comma, derive_debug)] diff --git a/servo/components/style/media_queries/media_query.rs b/servo/components/style/media_queries/media_query.rs index 46c35618b228..5875b5b38ea5 100644 --- a/servo/components/style/media_queries/media_query.rs +++ b/servo/components/style/media_queries/media_query.rs @@ -6,14 +6,14 @@ //! //! https://drafts.csswg.org/mediaqueries/#typedef-media-query -use Atom; +use super::media_condition::MediaCondition; use cssparser::Parser; use parser::ParserContext; use std::fmt::{self, Write}; use str::string_as_ascii_lowercase; use style_traits::{CssWriter, ParseError, ToCss}; -use super::media_condition::MediaCondition; use values::CustomIdent; +use Atom; /// #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)] @@ -130,7 +130,8 @@ impl MediaQuery { let ident = input.expect_ident().map_err(|_| ())?; let media_type = MediaQueryType::parse(&ident)?; Ok((qualifier, Some(media_type))) - }).unwrap_or_default(); + }) + .unwrap_or_default(); let condition = if explicit_media_type.is_none() { Some(MediaCondition::parse(context, input)?) diff --git a/servo/components/style/media_queries/mod.rs b/servo/components/style/media_queries/mod.rs index b59ec32443dc..93a5abf3b011 100644 --- a/servo/components/style/media_queries/mod.rs +++ b/servo/components/style/media_queries/mod.rs @@ -14,11 +14,11 @@ pub mod media_feature; pub mod media_feature_expression; pub use self::media_condition::MediaCondition; +pub use self::media_feature_expression::MediaFeatureExpression; pub use self::media_list::MediaList; pub use self::media_query::{MediaQuery, MediaQueryType, MediaType, Qualifier}; -pub use self::media_feature_expression::MediaFeatureExpression; -#[cfg(feature = "servo")] -pub use servo::media_queries::Device; #[cfg(feature = "gecko")] pub use gecko::media_queries::Device; +#[cfg(feature = "servo")] +pub use servo::media_queries::Device; diff --git a/servo/components/style/rule_tree/mod.rs b/servo/components/style/rule_tree/mod.rs index 59c06e58923f..c1b818892897 100644 --- a/servo/components/style/rule_tree/mod.rs +++ b/servo/components/style/rule_tree/mod.rs @@ -526,7 +526,8 @@ impl RuleTree { path, guards, &mut dummy, - ).expect("Should return a valid rule node") + ) + .expect("Should return a valid rule node") } } @@ -730,9 +731,9 @@ unsafe impl Send for RuleTree {} #[cfg(feature = "gecko")] #[cfg(debug_assertions)] mod gecko_leak_checking { + use super::RuleNode; use std::mem::size_of; use std::os::raw::{c_char, c_void}; - use super::RuleNode; extern "C" { pub fn NS_LogCtor(aPtr: *const c_void, aTypeName: *const c_char, aSize: u32); diff --git a/servo/components/style/selector_map.rs b/servo/components/style/selector_map.rs index 1e35f748917e..d9bf07710842 100644 --- a/servo/components/style/selector_map.rs +++ b/servo/components/style/selector_map.rs @@ -5,13 +5,12 @@ //! A data structure to efficiently index structs containing selectors by local //! name, ids and hash. -use {Atom, LocalName, Namespace, WeakAtom}; use applicable_declarations::ApplicableDeclarationList; use context::QuirksMode; use dom::TElement; use fallible::FallibleVec; -use hash::{HashMap, HashSet}; use hash::map as hash_map; +use hash::{HashMap, HashSet}; use hashglobe::FailedAllocationError; use precomputed_hash::PrecomputedHash; use rule_tree::{CascadeLevel, ShadowCascadeOrder}; @@ -21,6 +20,7 @@ use selectors::parser::{Combinator, Component, SelectorIter}; use smallvec::SmallVec; use std::hash::{BuildHasherDefault, Hash, Hasher}; use stylist::Rule; +use {Atom, LocalName, Namespace, WeakAtom}; /// A hasher implementation that doesn't hash anything, because it expects its /// input to be a suitable u32 hash. diff --git a/servo/components/style/selector_parser.rs b/servo/components/style/selector_parser.rs index 5d6ddbb0e3fa..1bfe115c5f47 100644 --- a/servo/components/style/selector_parser.rs +++ b/servo/components/style/selector_parser.rs @@ -6,7 +6,6 @@ #![deny(missing_docs)] -use Atom; use cssparser::{Parser as CssParser, ParserInput}; use element_state::ElementState; use selectors::parser::SelectorList; @@ -14,6 +13,7 @@ use std::fmt::{self, Debug, Write}; use style_traits::{CssWriter, ParseError, ToCss}; use stylesheets::{Namespaces, Origin, UrlExtraData}; use values::serialize_atom_identifier; +use Atom; /// A convenient alias for the type that represents an attribute value used for /// selector parser implementation. diff --git a/servo/components/style/servo/media_queries.rs b/servo/components/style/servo/media_queries.rs index bae0aa3978b9..77113e703c38 100644 --- a/servo/components/style/servo/media_queries.rs +++ b/servo/components/style/servo/media_queries.rs @@ -8,17 +8,17 @@ use app_units::Au; use cssparser::RGBA; use custom_properties::CssEnvironment; use euclid::{Size2D, TypedScale, TypedSize2D}; -use media_queries::MediaType; use media_queries::media_feature::{AllowsRanges, ParsingRequirements}; -use media_queries::media_feature::{MediaFeatureDescription, Evaluator}; +use media_queries::media_feature::{Evaluator, MediaFeatureDescription}; use media_queries::media_feature_expression::RangeOrOperator; +use media_queries::MediaType; use properties::ComputedValues; use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering}; -use style_traits::{CSSPixel, DevicePixel}; use style_traits::viewport::ViewportConstraints; -use values::KeyframesName; -use values::computed::CSSPixelLength; +use style_traits::{CSSPixel, DevicePixel}; use values::computed::font::FontSize; +use values::computed::CSSPixelLength; +use values::KeyframesName; /// A device is a structure that represents the current media a given document /// is displayed in. diff --git a/servo/components/style/servo/restyle_damage.rs b/servo/components/style/servo/restyle_damage.rs index 7b49a592751e..5f6eaa4c26fa 100644 --- a/servo/components/style/servo/restyle_damage.rs +++ b/servo/components/style/servo/restyle_damage.rs @@ -195,7 +195,7 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam let mut damage = ServoRestyleDamage::empty(); // This should check every CSS property, as enumerated in the fields of - // http://doc.servo.org/style/properties/struct.ComputedValues.html + // https://doc.servo.org/style/properties/struct.ComputedValues.html // This uses short-circuiting boolean OR for its side effects and ignores the result. let _ = restyle_damage_rebuild_and_reflow!( diff --git a/servo/components/style/servo/selector_parser.rs b/servo/components/style/servo/selector_parser.rs index de8257dcc4ca..97fb3e298547 100644 --- a/servo/components/style/servo/selector_parser.rs +++ b/servo/components/style/servo/selector_parser.rs @@ -6,7 +6,6 @@ //! Servo's selector parser. -use {Atom, CaseSensitivityExt, LocalName, Namespace, Prefix}; use attr::{AttrIdentifier, AttrValue}; use cssparser::{serialize_identifier, CowRcStr, Parser as CssParser, SourceLocation, ToCss}; use dom::{OpaqueNode, TElement, TNode}; @@ -14,8 +13,8 @@ use element_state::{DocumentState, ElementState}; use fxhash::FxHashMap; use invalidation::element::document_state::InvalidationMatchingData; use invalidation::element::element_wrapper::ElementSnapshot; -use properties::{ComputedValues, PropertyFlags}; use properties::longhands::display::computed_value::T as Display; +use properties::{ComputedValues, PropertyFlags}; use selector_parser::{AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser}; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::parser::{SelectorParseErrorKind, Visit}; @@ -24,6 +23,7 @@ use std::fmt; use std::mem; use std::ops::{Deref, DerefMut}; use style_traits::{ParseError, StyleParseErrorKind}; +use {Atom, CaseSensitivityExt, LocalName, Namespace, Prefix}; /// A pseudo-element, both public and private. /// @@ -348,8 +348,8 @@ impl NonTSPseudoClass { /// Gets a given state flag for this pseudo-class. This is used to do /// selector matching, and it's set from the DOM. pub fn state_flag(&self) -> ElementState { - use element_state::ElementState; use self::NonTSPseudoClass::*; + use element_state::ElementState; match *self { Active => ElementState::IN_ACTIVE_STATE, Focus => ElementState::IN_FOCUS_STATE, diff --git a/servo/components/style/sharing/mod.rs b/servo/components/style/sharing/mod.rs index 23916ce7ff42..f4ac8f30b135 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 Atom; use applicable_declarations::ApplicableDeclarationBlock; use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use bloom::StyleBloom; @@ -74,8 +73,8 @@ use matching::MatchMethods; use owning_ref::OwningHandle; use properties::ComputedValues; use rule_tree::StrongRuleNode; -use selectors::NthIndexCache; use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode}; +use selectors::NthIndexCache; use servo_arc::Arc; use smallbitvec::SmallBitVec; use smallvec::SmallVec; @@ -86,6 +85,7 @@ use std::ptr::NonNull; use style_resolver::{PrimaryStyle, ResolvedElementStyles}; use stylist::Stylist; use uluru::{Entry, LRUCache}; +use Atom; mod checks; @@ -120,9 +120,8 @@ unsafe impl Sync for OpaqueComputedValues {} impl OpaqueComputedValues { fn from(cv: &ComputedValues) -> Self { - let p = unsafe { - NonNull::new_unchecked(cv as *const ComputedValues as *const () as *mut ()) - }; + let p = + unsafe { NonNull::new_unchecked(cv as *const ComputedValues as *const () as *mut ()) }; OpaqueComputedValues(p) } @@ -204,7 +203,8 @@ impl ValidationData { let values = OpaqueComputedValues::from(parent.borrow_data().unwrap().styles.primary()); values - }).clone() + }) + .clone() } /// Computes the revalidation results if needed, and returns it. diff --git a/servo/components/style/style_adjuster.rs b/servo/components/style/style_adjuster.rs index af53e3dcc7b0..0b6005197b37 100644 --- a/servo/components/style/style_adjuster.rs +++ b/servo/components/style/style_adjuster.rs @@ -7,12 +7,12 @@ use app_units::Au; use dom::TElement; -use properties::{self, ComputedValues, StyleBuilder}; use properties::computed_value_flags::ComputedValueFlags; use properties::longhands::display::computed_value::T as Display; use properties::longhands::float::computed_value::T as Float; use properties::longhands::overflow_x::computed_value::T as Overflow; use properties::longhands::position::computed_value::T as Position; +use properties::{self, ComputedValues, StyleBuilder}; /// A struct that implements all the adjustment methods. /// @@ -713,12 +713,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { if self.style.pseudo.is_some() { return; } - let is_html_select_element = - element.map_or(false, |e| e.is_html_element() && e.local_name() == &*local_name!("select")); + let is_html_select_element = element.map_or(false, |e| { + e.is_html_element() && e.local_name() == &*local_name!("select") + }); if !is_html_select_element { return; } - self.style.mutate_inherited_text().set_line_height(LineHeight::normal()); + self.style + .mutate_inherited_text() + .set_line_height(LineHeight::normal()); } } diff --git a/servo/components/style/style_resolver.rs b/servo/components/style/style_resolver.rs index 0899faa9ce7a..f1328858c3d9 100644 --- a/servo/components/style/style_resolver.rs +++ b/servo/components/style/style_resolver.rs @@ -10,11 +10,13 @@ use data::{EagerPseudoStyles, ElementStyles}; use dom::TElement; use log::Level::Trace; use matching::MatchMethods; -use properties::{AnimationRules, ComputedValues}; use properties::longhands::display::computed_value::T as Display; +use properties::{AnimationRules, ComputedValues}; use rule_tree::StrongRuleNode; use selector_parser::{PseudoElement, SelectorImpl}; -use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, VisitedHandlingMode}; +use selectors::matching::{ + ElementSelectorFlags, MatchingContext, MatchingMode, VisitedHandlingMode, +}; use servo_arc::Arc; use stylist::RuleInclusion; diff --git a/servo/components/style/stylesheets/document_rule.rs b/servo/components/style/stylesheets/document_rule.rs index 9598763e4386..4dc36953ee2e 100644 --- a/servo/components/style/stylesheets/document_rule.rs +++ b/servo/components/style/stylesheets/document_rule.rs @@ -120,7 +120,8 @@ macro_rules! parse_quoted_or_unquoted_string { .parse_entirely(|input| { let string = input.expect_string()?; Ok($url_matching_function(string.as_ref().to_owned())) - }).or_else(|_: ParseError| { + }) + .or_else(|_: ParseError| { while let Ok(_) = input.next() {} Ok($url_matching_function(input.slice_from(start).to_string())) }) diff --git a/servo/components/style/stylesheets/font_feature_values_rule.rs b/servo/components/style/stylesheets/font_feature_values_rule.rs index f1353744f08d..548b060e0142 100644 --- a/servo/components/style/stylesheets/font_feature_values_rule.rs +++ b/servo/components/style/stylesheets/font_feature_values_rule.rs @@ -6,7 +6,6 @@ //! //! [font-feature-values]: https://drafts.csswg.org/css-fonts-3/#at-font-feature-values-rule -use Atom; use cssparser::{AtRuleParser, AtRuleType, BasicParseErrorKind, CowRcStr}; use cssparser::{DeclarationListParser, DeclarationParser, Parser}; use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, Token}; @@ -23,6 +22,7 @@ use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use stylesheets::CssRuleType; use values::computed::font::FamilyName; use values::serialize_atom_identifier; +use Atom; /// A @font-feature-values block declaration. /// It is `: +`. diff --git a/servo/components/style/stylesheets/keyframes_rule.rs b/servo/components/style/stylesheets/keyframes_rule.rs index 50c61047e529..ffd415513946 100644 --- a/servo/components/style/stylesheets/keyframes_rule.rs +++ b/servo/components/style/stylesheets/keyframes_rule.rs @@ -4,23 +4,23 @@ //! Keyframes: https://drafts.csswg.org/css-animations/#keyframes -use cssparser::{AtRuleParser, CowRcStr, Parser, ParserInput, QualifiedRuleParser, RuleListParser}; use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, SourceLocation, Token}; +use cssparser::{AtRuleParser, CowRcStr, Parser, ParserInput, QualifiedRuleParser, RuleListParser}; use error_reporting::ContextualParseError; use parser::ParserContext; +use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; +use properties::LonghandIdSet; use properties::{Importance, PropertyDeclaration}; use properties::{LonghandId, PropertyDeclarationBlock, PropertyId}; use properties::{PropertyDeclarationId, SourcePropertyDeclaration}; -use properties::LonghandIdSet; -use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; use servo_arc::Arc; use shared_lock::{DeepCloneParams, DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard}; use shared_lock::{Locked, ToCssWithGuard}; use std::fmt::{self, Write}; use str::CssStringWriter; use style_traits::{CssWriter, ParseError, ParsingMode, StyleParseErrorKind, ToCss}; -use stylesheets::{CssRuleType, StylesheetContents}; use stylesheets::rule_parser::VendorPrefix; +use stylesheets::{CssRuleType, StylesheetContents}; use values::{serialize_percentage, KeyframesName}; /// A [`@keyframes`][keyframes] rule. @@ -89,7 +89,8 @@ impl DeepCloneWithLock for KeyframesRule { Arc::new( lock.wrap(x.read_with(guard).deep_clone_with_lock(lock, guard, params)), ) - }).collect(), + }) + .collect(), vendor_prefix: self.vendor_prefix.clone(), source_location: self.source_location.clone(), } @@ -327,7 +328,8 @@ impl KeyframesStep { let (declaration, _) = guard .get(PropertyDeclarationId::Longhand( LonghandId::AnimationTimingFunction, - )).unwrap(); + )) + .unwrap(); match *declaration { PropertyDeclaration::AnimationTimingFunction(ref value) => { // Use the first value. @@ -499,7 +501,8 @@ pub fn parse_keyframe_list( shared_lock: shared_lock, declarations: &mut declarations, }, - ).filter_map(Result::ok) + ) + .filter_map(Result::ok) .collect() } diff --git a/servo/components/style/stylesheets/mod.rs b/servo/components/style/stylesheets/mod.rs index 81726950665e..9e1ae186d55c 100644 --- a/servo/components/style/stylesheets/mod.rs +++ b/servo/components/style/stylesheets/mod.rs @@ -45,13 +45,13 @@ pub use self::media_rule::MediaRule; pub use self::namespace_rule::NamespaceRule; pub use self::origin::{Origin, OriginSet, OriginSetIterator, PerOrigin, PerOriginIter}; pub use self::page_rule::PageRule; -pub use self::rule_parser::{State, TopLevelRuleParser, InsertRuleContext}; 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, RulesIterator}; +pub use self::style_rule::StyleRule; pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet}; pub use self::stylesheet::{StylesheetContents, StylesheetInDocument, UserAgentStylesheets}; -pub use self::style_rule::StyleRule; pub use self::supports_rule::SupportsRule; pub use self::viewport_rule::ViewportRule; @@ -88,7 +88,7 @@ impl UrlExtraData { #[cfg(feature = "gecko")] impl fmt::Debug for UrlExtraData { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - use gecko_bindings::{structs, bindings}; + use gecko_bindings::{bindings, structs}; struct DebugURI(*mut structs::nsIURI); impl fmt::Debug for DebugURI { @@ -109,7 +109,8 @@ impl fmt::Debug for UrlExtraData { .field( "referrer", &DebugURI(self.0.mReferrer.raw::()), - ).finish() + ) + .finish() } } diff --git a/servo/components/style/stylesheets/namespace_rule.rs b/servo/components/style/stylesheets/namespace_rule.rs index f28f2ba0881a..1f927f08f172 100644 --- a/servo/components/style/stylesheets/namespace_rule.rs +++ b/servo/components/style/stylesheets/namespace_rule.rs @@ -4,11 +4,11 @@ //! The `@namespace` at-rule. -use {Namespace, Prefix}; use cssparser::SourceLocation; use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; use str::CssStringWriter; +use {Namespace, Prefix}; /// A `@namespace` rule. #[derive(Clone, Debug, PartialEq)] diff --git a/servo/components/style/stylesheets/rule_list.rs b/servo/components/style/stylesheets/rule_list.rs index cfbf62ea721a..280f879a77b9 100644 --- a/servo/components/style/stylesheets/rule_list.rs +++ b/servo/components/style/stylesheets/rule_list.rs @@ -11,10 +11,10 @@ use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; use str::CssStringWriter; -use stylesheets::{CssRule, RulesMutateError}; use stylesheets::loader::StylesheetLoader; use stylesheets::rule_parser::{InsertRuleContext, State}; use stylesheets::stylesheet::StylesheetContents; +use stylesheets::{CssRule, RulesMutateError}; /// A list of CSS rules. #[derive(Debug)] diff --git a/servo/components/style/stylesheets/rule_parser.rs b/servo/components/style/stylesheets/rule_parser.rs index aa449c70e934..642eabd9b6ab 100644 --- a/servo/components/style/stylesheets/rule_parser.rs +++ b/servo/components/style/stylesheets/rule_parser.rs @@ -4,7 +4,6 @@ //! Parsing of the stylesheet contents. -use {Namespace, Prefix}; use counter_style::{parse_counter_style_body, parse_counter_style_name_definition}; use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser}; use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, SourceLocation}; @@ -19,17 +18,18 @@ use servo_arc::Arc; use shared_lock::{Locked, SharedRwLock}; use str::starts_with_ignore_ascii_case; use style_traits::{ParseError, StyleParseErrorKind}; -use stylesheets::{CssRule, CssRuleType, CssRules, RulesMutateError, StylesheetLoader}; -use stylesheets::{DocumentRule, FontFeatureValuesRule, KeyframesRule, MediaRule}; -use stylesheets::{NamespaceRule, PageRule, StyleRule, SupportsRule, ViewportRule}; use stylesheets::document_rule::DocumentCondition; use stylesheets::font_feature_values_rule::parse_family_name_list; use stylesheets::keyframes_rule::parse_keyframe_list; use stylesheets::stylesheet::Namespaces; use stylesheets::supports_rule::SupportsCondition; use stylesheets::viewport_rule; -use values::{CssUrl, CustomIdent, KeyframesName}; +use stylesheets::{CssRule, CssRuleType, CssRules, RulesMutateError, StylesheetLoader}; +use stylesheets::{DocumentRule, FontFeatureValuesRule, KeyframesRule, MediaRule}; +use stylesheets::{NamespaceRule, PageRule, StyleRule, SupportsRule, ViewportRule}; use values::computed::font::FamilyName; +use values::{CssUrl, CustomIdent, KeyframesName}; +use {Namespace, Prefix}; /// The information we need particularly to do CSSOM insertRule stuff. pub struct InsertRuleContext<'a> { diff --git a/servo/components/style/stylesheets/rules_iterator.rs b/servo/components/style/stylesheets/rules_iterator.rs index eac6d2084e2a..5609e75f215b 100644 --- a/servo/components/style/stylesheets/rules_iterator.rs +++ b/servo/components/style/stylesheets/rules_iterator.rs @@ -9,8 +9,8 @@ use media_queries::Device; use shared_lock::SharedRwLockReadGuard; use smallvec::SmallVec; use std::slice; -use stylesheets::{CssRule, DocumentRule, ImportRule, MediaRule, SupportsRule}; use stylesheets::StylesheetInDocument; +use stylesheets::{CssRule, DocumentRule, ImportRule, MediaRule, SupportsRule}; /// An iterator over a list of rules. pub struct RulesIterator<'a, 'b, C> diff --git a/servo/components/style/stylesheets/style_rule.rs b/servo/components/style/stylesheets/style_rule.rs index c161cc43ee21..a017b38bdf52 100644 --- a/servo/components/style/stylesheets/style_rule.rs +++ b/servo/components/style/stylesheets/style_rule.rs @@ -6,9 +6,9 @@ use cssparser::SourceLocation; #[cfg(feature = "gecko")] -use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; -#[cfg(feature = "gecko")] use malloc_size_of::MallocUnconditionalShallowSizeOf; +#[cfg(feature = "gecko")] +use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use properties::PropertyDeclarationBlock; use selector_parser::SelectorImpl; use selectors::SelectorList; diff --git a/servo/components/style/stylesheets/stylesheet.rs b/servo/components/style/stylesheets/stylesheet.rs index ac1d810a05bb..9bdc9c6834bf 100644 --- a/servo/components/style/stylesheets/stylesheet.rs +++ b/servo/components/style/stylesheets/stylesheet.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use {Namespace, Prefix}; use context::QuirksMode; use cssparser::{Parser, ParserInput, RuleListParser}; use error_reporting::{ContextualParseError, ParseErrorReporter}; @@ -15,16 +14,19 @@ use media_queries::{Device, MediaList}; use parking_lot::RwLock; use parser::ParserContext; use servo_arc::Arc; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard}; +use shared_lock::{ + DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, +}; use std::mem; use std::sync::atomic::{AtomicBool, Ordering}; use style_traits::ParsingMode; -use stylesheets::{CssRule, CssRules, Origin, UrlExtraData}; use stylesheets::loader::StylesheetLoader; use stylesheets::rule_parser::{State, TopLevelRuleParser}; use stylesheets::rules_iterator::{EffectiveRules, EffectiveRulesIterator}; use stylesheets::rules_iterator::{NestedRuleIterationCondition, RulesIterator}; +use stylesheets::{CssRule, CssRules, Origin, UrlExtraData}; use use_counters::UseCounters; +use {Namespace, Prefix}; /// This structure holds the user-agent and user stylesheets. pub struct UserAgentStylesheets { diff --git a/servo/components/style/stylesheets/supports_rule.rs b/servo/components/style/stylesheets/supports_rule.rs index 06a7807e41dc..a273dcb48a92 100644 --- a/servo/components/style/stylesheets/supports_rule.rs +++ b/servo/components/style/stylesheets/supports_rule.rs @@ -4,9 +4,9 @@ //! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports) +use cssparser::parse_important; use cssparser::{Delimiter, Parser, SourceLocation, Token}; use cssparser::{ParseError as CssParseError, ParserInput}; -use cssparser::parse_important; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; use parser::ParserContext; @@ -172,9 +172,7 @@ impl SupportsCondition { } /// - fn parse_in_parens<'i, 't>( - input: &mut Parser<'i, 't>, - ) -> Result> { + fn parse_in_parens<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { // Whitespace is normally taken care of in `Parser::next`, // but we want to not include it in `pos` for the SupportsCondition::FutureSyntax cases. while input.try(Parser::expect_whitespace).is_ok() {} @@ -183,9 +181,8 @@ impl SupportsCondition { // FIXME: remove clone() when lifetimes are non-lexical match input.next()?.clone() { Token::ParenthesisBlock => { - let nested = input.try(|input| { - input.parse_nested_block(parse_condition_or_declaration) - }); + let nested = + input.try(|input| input.parse_nested_block(parse_condition_or_declaration)); if nested.is_ok() { return nested; } @@ -209,11 +206,7 @@ impl SupportsCondition { } /// Evaluate a supports condition - pub fn eval( - &self, - cx: &ParserContext, - namespaces: &Namespaces, - ) -> bool { + pub fn eval(&self, cx: &ParserContext, namespaces: &Namespaces) -> bool { match *self { SupportsCondition::Not(ref cond) => !cond.eval(cx, namespaces), SupportsCondition::Parenthesized(ref cond) => cond.eval(cx, namespaces), @@ -300,7 +293,7 @@ impl ToCss for SupportsCondition { dest.write_str("selector(")?; selector.to_css(dest)?; dest.write_str(")") - } + }, SupportsCondition::MozBoolPref(ref name) => { dest.write_str("-moz-bool-pref(")?; let name = @@ -328,51 +321,51 @@ impl ToCss for RawSelector { impl RawSelector { /// Tries to evaluate a `selector()` function. - pub fn eval( - &self, - context: &ParserContext, - namespaces: &Namespaces, - ) -> bool { + pub fn eval(&self, context: &ParserContext, namespaces: &Namespaces) -> bool { #[cfg(feature = "gecko")] { - if unsafe { !::gecko_bindings::structs::StaticPrefs_sVarCache_layout_css_supports_selector_enabled } { + if unsafe { + !::gecko_bindings::structs::StaticPrefs_sVarCache_layout_css_supports_selector_enabled + } { return false; } } let mut input = ParserInput::new(&self.0); let mut input = Parser::new(&mut input); - input.parse_entirely(|input| -> Result<(), CssParseError<()>> { - let parser = SelectorParser { - namespaces, - stylesheet_origin: context.stylesheet_origin, - url_data: Some(context.url_data), - }; + input + .parse_entirely(|input| -> Result<(), CssParseError<()>> { + let parser = SelectorParser { + namespaces, + stylesheet_origin: context.stylesheet_origin, + url_data: Some(context.url_data), + }; - #[allow(unused_variables)] - let selector = Selector::::parse(&parser, input) - .map_err(|_| input.new_custom_error(()))?; + #[allow(unused_variables)] + let selector = Selector::::parse(&parser, input) + .map_err(|_| input.new_custom_error(()))?; - #[cfg(feature = "gecko")] - { - use selector_parser::PseudoElement; - use selectors::parser::Component; + #[cfg(feature = "gecko")] + { + use selector_parser::PseudoElement; + use selectors::parser::Component; - let has_any_unknown_webkit_pseudo = - selector.has_pseudo_element() && - selector.iter_raw_match_order().any(|component| { - matches!( - *component, - Component::PseudoElement(PseudoElement::UnknownWebkit(..)) - ) - }); - if has_any_unknown_webkit_pseudo { - return Err(input.new_custom_error(())); + let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() && selector + .iter_raw_match_order() + .any(|component| { + matches!( + *component, + Component::PseudoElement(PseudoElement::UnknownWebkit(..)) + ) + }); + if has_any_unknown_webkit_pseudo { + return Err(input.new_custom_error(())); + } } - } - Ok(()) - }).is_ok() + Ok(()) + }) + .is_ok() } } @@ -412,20 +405,22 @@ impl Declaration { let mut input = ParserInput::new(&self.0); let mut input = Parser::new(&mut input); - input.parse_entirely(|input| -> Result<(), CssParseError<()>> { - let prop = input.expect_ident_cloned().unwrap(); - input.expect_colon().unwrap(); + input + .parse_entirely(|input| -> Result<(), CssParseError<()>> { + let prop = input.expect_ident_cloned().unwrap(); + input.expect_colon().unwrap(); - let id = - PropertyId::parse(&prop, context).map_err(|_| input.new_custom_error(()))?; + let id = + PropertyId::parse(&prop, context).map_err(|_| input.new_custom_error(()))?; - let mut declarations = SourcePropertyDeclaration::new(); - input.parse_until_before(Delimiter::Bang, |input| { - PropertyDeclaration::parse_into(&mut declarations, id, &context, input) - .map_err(|_| input.new_custom_error(())) - })?; - let _ = input.try(parse_important); - Ok(()) - }).is_ok() + let mut declarations = SourcePropertyDeclaration::new(); + input.parse_until_before(Delimiter::Bang, |input| { + PropertyDeclaration::parse_into(&mut declarations, id, &context, input) + .map_err(|_| input.new_custom_error(())) + })?; + let _ = input.try(parse_important); + Ok(()) + }) + .is_ok() } } diff --git a/servo/components/style/stylesheets/viewport_rule.rs b/servo/components/style/stylesheets/viewport_rule.rs index 16bffd14ab29..741e577229d2 100644 --- a/servo/components/style/stylesheets/viewport_rule.rs +++ b/servo/components/style/stylesheets/viewport_rule.rs @@ -9,8 +9,8 @@ use app_units::Au; use context::QuirksMode; -use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; use cssparser::CowRcStr; +use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; use error_reporting::ContextualParseError; use euclid::TypedSize2D; use font_metrics::get_metrics_provider_for_product; @@ -26,8 +26,8 @@ use std::fmt::{self, Write}; use std::iter::Enumerate; use std::str::Chars; use str::CssStringWriter; -use style_traits::{CssWriter, ParseError, PinchZoomFactor, StyleParseErrorKind, ToCss}; use style_traits::viewport::{Orientation, UserZoom, ViewportConstraints, Zoom}; +use style_traits::{CssWriter, ParseError, PinchZoomFactor, StyleParseErrorKind, ToCss}; use stylesheets::{Origin, StylesheetInDocument}; use values::computed::{Context, ToComputedValue}; use values::specified::{LengthOrPercentageOrAuto, NoCalcLength, ViewportPercentageLength}; diff --git a/servo/components/style/stylist.rs b/servo/components/style/stylist.rs index 2772891a3db1..cd6ed7257e57 100644 --- a/servo/components/style/stylist.rs +++ b/servo/components/style/stylist.rs @@ -4,7 +4,6 @@ //! Selector matching. -use {Atom, LocalName, Namespace, WeakAtom}; use applicable_declarations::{ApplicableDeclarationBlock, ApplicableDeclarationList}; use context::{CascadeInputs, QuirksMode}; use dom::{TElement, TShadowRoot}; @@ -16,9 +15,9 @@ use hashglobe::FailedAllocationError; use invalidation::element::invalidation_map::InvalidationMap; use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey}; #[cfg(feature = "gecko")] -use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps}; -#[cfg(feature = "gecko")] use malloc_size_of::MallocUnconditionalShallowSizeOf; +#[cfg(feature = "gecko")] +use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps}; use media_queries::Device; use properties::{self, CascadeMode, ComputedValues}; use properties::{AnimationRules, PropertyDeclarationBlock}; @@ -26,14 +25,14 @@ use rule_cache::{RuleCache, RuleCacheConditions}; use rule_tree::{CascadeLevel, RuleTree, ShadowCascadeOrder, StrongRuleNode, StyleSource}; use selector_map::{PrecomputedHashMap, PrecomputedHashSet, SelectorMap, SelectorMapEntry}; use selector_parser::{PerPseudoElementMap, PseudoElement, SelectorImpl, SnapshotMap}; -use selectors::NthIndexCache; use selectors::attr::{CaseSensitivity, NamespaceConstraint}; use selectors::bloom::BloomFilter; -use selectors::matching::{matches_selector, ElementSelectorFlags, MatchingContext, MatchingMode}; use selectors::matching::VisitedHandlingMode; +use selectors::matching::{matches_selector, ElementSelectorFlags, MatchingContext, MatchingMode}; use selectors::parser::{AncestorHashes, Combinator, Component, Selector}; use selectors::parser::{SelectorIter, Visit}; use selectors::visitor::SelectorVisitor; +use selectors::NthIndexCache; use servo_arc::{Arc, ArcBorrow}; use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; use smallbitvec::SmallBitVec; @@ -43,14 +42,15 @@ use std::sync::Mutex; use style_traits::viewport::ViewportConstraints; use stylesheet_set::{DataValidity, DocumentStylesheetSet, SheetRebuildKind}; use stylesheet_set::{DocumentStylesheetFlusher, SheetCollectionFlusher}; +use stylesheets::keyframes_rule::KeyframesAnimation; +use stylesheets::viewport_rule::{self, MaybeNew, ViewportRule}; +use stylesheets::StyleRule; +use stylesheets::StylesheetInDocument; #[cfg(feature = "gecko")] use stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule}; use stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter}; -use stylesheets::StyleRule; -use stylesheets::StylesheetInDocument; -use stylesheets::keyframes_rule::KeyframesAnimation; -use stylesheets::viewport_rule::{self, MaybeNew, ViewportRule}; use thread_state::{self, ThreadState}; +use {Atom, LocalName, Namespace, WeakAtom}; /// The type of the stylesheets that the stylist contains. #[cfg(feature = "servo")] @@ -517,7 +517,8 @@ impl Stylist { self.stylesheets.iter(), guards, &self.device, - ).finish(), + ) + .finish(), }; self.viewport_constraints = @@ -1017,7 +1018,8 @@ impl Stylist { stylesheets.clone(), guards, &device, - ).finish(), + ) + .finish(), } }; @@ -1535,7 +1537,6 @@ impl Stylist { ); } - results } diff --git a/servo/components/style/traversal.rs b/servo/components/style/traversal.rs index 5f81f3544a91..d207c196d66f 100644 --- a/servo/components/style/traversal.rs +++ b/servo/components/style/traversal.rs @@ -361,7 +361,8 @@ where context, rule_inclusion, PseudoElementResolution::IfApplicable, - ).resolve_primary_style( + ) + .resolve_primary_style( style.as_ref().map(|s| &**s), layout_parent_style.as_ref().map(|s| &**s), ); @@ -382,10 +383,12 @@ where context, rule_inclusion, PseudoElementResolution::Force, - ).resolve_style( + ) + .resolve_style( style.as_ref().map(|s| &**s), layout_parent_style.as_ref().map(|s| &**s), - ).into() + ) + .into() } /// Calculates the style for a single node. @@ -717,8 +720,8 @@ where E: TElement, { use style_traits::ToCss; - use values::Either; use values::generics::image::Image; + use values::Either; // We speculatively evaluate any paint worklets during styling. // This allows us to run paint worklets in parallel with style and layout. diff --git a/servo/components/style/values/animated/effects.rs b/servo/components/style/values/animated/effects.rs index a86396506df5..674a601764ac 100644 --- a/servo/components/style/values/animated/effects.rs +++ b/servo/components/style/values/animated/effects.rs @@ -4,16 +4,16 @@ //! Animated types for CSS values related to effects. -#[cfg(not(feature = "gecko"))] -use values::Impossible; use values::animated::color::Color; -use values::computed::{Angle, Number}; use values::computed::length::Length; #[cfg(feature = "gecko")] use values::computed::url::ComputedUrl; +use values::computed::{Angle, Number}; use values::generics::effects::BoxShadow as GenericBoxShadow; use values::generics::effects::Filter as GenericFilter; use values::generics::effects::SimpleShadow as GenericSimpleShadow; +#[cfg(not(feature = "gecko"))] +use values::Impossible; /// An animated value for a single `box-shadow`. pub type BoxShadow = GenericBoxShadow; diff --git a/servo/components/style/values/animated/font.rs b/servo/components/style/values/animated/font.rs index 5a85bc14b182..65050ffe1da7 100644 --- a/servo/components/style/values/animated/font.rs +++ b/servo/components/style/values/animated/font.rs @@ -5,8 +5,8 @@ //! Animation implementation for various font-related types. use super::{Animate, Procedure, ToAnimatedZero}; +use values::computed::font::{FontVariationSettings, FontWeight}; use values::computed::Number; -use values::computed::font::{FontWeight, FontVariationSettings}; use values::distance::{ComputeSquaredDistance, SquaredDistance}; use values::generics::font::{FontSettings as GenericFontSettings, FontTag, VariationValue}; @@ -143,7 +143,9 @@ impl<'a> FontSettingTagIter<'a> { impl<'a> Iterator for FontSettingTagIter<'a> { type Item = Result<(&'a ComputedVariationValue, &'a ComputedVariationValue), ()>; - fn next(&mut self) -> Option> { + fn next( + &mut self, + ) -> Option> { match ( FontSettingTagIter::next_tag(&mut self.a_state), FontSettingTagIter::next_tag(&mut self.b_state), diff --git a/servo/components/style/values/animated/length.rs b/servo/components/style/values/animated/length.rs index f655ec33a2d8..5b47103f0ea5 100644 --- a/servo/components/style/values/animated/length.rs +++ b/servo/components/style/values/animated/length.rs @@ -5,10 +5,12 @@ //! Animation implementation for various length-related types. use super::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; +use values::computed::length::{ + CalcLengthOrPercentage, Length, LengthOrPercentageOrAuto, LengthOrPercentageOrNone, +}; use values::computed::MaxLength as ComputedMaxLength; use values::computed::MozLength as ComputedMozLength; use values::computed::Percentage; -use values::computed::length::{Length, CalcLengthOrPercentage, LengthOrPercentageOrNone, LengthOrPercentageOrAuto}; /// impl Animate for CalcLengthOrPercentage { @@ -23,9 +25,15 @@ impl Animate for CalcLengthOrPercentage { Ok(Some(this.animate(&other, procedure)?)) }; - let length = self.unclamped_length().animate(&other.unclamped_length(), procedure)?; + let length = self + .unclamped_length() + .animate(&other.unclamped_length(), procedure)?; let percentage = animate_percentage_half(self.percentage, other.percentage)?; - Ok(CalcLengthOrPercentage::with_clamping_mode(length, percentage, self.clamping_mode)) + Ok(CalcLengthOrPercentage::with_clamping_mode( + length, + percentage, + self.clamping_mode, + )) } } diff --git a/servo/components/style/values/animated/mod.rs b/servo/components/style/values/animated/mod.rs index 3fe369c4e914..707fc263c70a 100644 --- a/servo/components/style/values/animated/mod.rs +++ b/servo/components/style/values/animated/mod.rs @@ -13,10 +13,10 @@ use euclid::{Point2D, Size2D}; use properties::PropertyId; use smallvec::SmallVec; use std::cmp; -use values::computed::Angle as ComputedAngle; -use values::computed::BorderCornerRadius as ComputedBorderCornerRadius; use values::computed::length::CalcLengthOrPercentage; use values::computed::url::ComputedUrl; +use values::computed::Angle as ComputedAngle; +use values::computed::BorderCornerRadius as ComputedBorderCornerRadius; pub mod color; pub mod effects; @@ -38,16 +38,16 @@ enum PropertyCategory { impl PropertyCategory { fn of(id: &PropertyId) -> Self { match *id { - PropertyId::Shorthand(..) | - PropertyId::ShorthandAlias(..) => PropertyCategory::Shorthand, - PropertyId::Longhand(id) | - PropertyId::LonghandAlias(id, ..) => { + PropertyId::Shorthand(..) | PropertyId::ShorthandAlias(..) => { + PropertyCategory::Shorthand + }, + PropertyId::Longhand(id) | PropertyId::LonghandAlias(id, ..) => { if id.is_logical() { PropertyCategory::LogicalLonghand } else { PropertyCategory::PhysicalLonghand } - } + }, PropertyId::Custom(..) => PropertyCategory::Custom, } } @@ -81,9 +81,9 @@ pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Orderin // name. let subprop_count_a = a.longhands().count(); let subprop_count_b = b.longhands().count(); - subprop_count_a.cmp(&subprop_count_b).then_with(|| { - a.idl_name_sort_order().cmp(&b.idl_name_sort_order()) - }) + subprop_count_a + .cmp(&subprop_count_b) + .then_with(|| a.idl_name_sort_order().cmp(&b.idl_name_sort_order())) } /// Animate from one value to another. diff --git a/servo/components/style/values/animated/svg.rs b/servo/components/style/values/animated/svg.rs index df8c43368a1a..630a2203252e 100644 --- a/servo/components/style/values/animated/svg.rs +++ b/servo/components/style/values/animated/svg.rs @@ -4,14 +4,14 @@ //! Animation implementations for various SVG-related types. -use properties::animated_properties::ListAnimation; use super::{Animate, Procedure, ToAnimatedZero}; +use properties::animated_properties::ListAnimation; use values::animated::color::Color as AnimatedColor; -use values::computed::{Number, NumberOrPercentage, LengthOrPercentage}; use values::computed::url::ComputedUrl; +use values::computed::{LengthOrPercentage, Number, NumberOrPercentage}; use values::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::generics::svg::{SVGLength, SvgLengthOrPercentageOrNumber, SVGPaint}; -use values::generics::svg::{SVGStrokeDashArray, SVGOpacity}; +use values::generics::svg::{SVGLength, SVGPaint, SvgLengthOrPercentageOrNumber}; +use values::generics::svg::{SVGOpacity, SVGStrokeDashArray}; /// Animated SVGPaint. pub type IntermediateSVGPaint = SVGPaint; @@ -32,13 +32,11 @@ fn to_number_or_percentage( value: &SvgLengthOrPercentageOrNumber, ) -> Result { Ok(match *value { - SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref l) => { - match *l { - LengthOrPercentage::Length(ref l) => NumberOrPercentage::Number(l.px()), - LengthOrPercentage::Percentage(ref p) => NumberOrPercentage::Percentage(*p), - LengthOrPercentage::Calc(..) => return Err(()), - } - } + SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref l) => match *l { + LengthOrPercentage::Length(ref l) => NumberOrPercentage::Number(l.px()), + LengthOrPercentage::Percentage(ref p) => NumberOrPercentage::Percentage(*p), + LengthOrPercentage::Calc(..) => return Err(()), + }, SvgLengthOrPercentageOrNumber::Number(ref n) => NumberOrPercentage::Number(*n), }) } @@ -50,22 +48,15 @@ impl Animate for SvgLengthOrPercentageOrNumber { let other = to_number_or_percentage(other)?; match (this, other) { - ( - NumberOrPercentage::Number(ref this), - NumberOrPercentage::Number(ref other), - ) => { - Ok(SvgLengthOrPercentageOrNumber::Number( - this.animate(other, procedure)? - )) - }, + (NumberOrPercentage::Number(ref this), NumberOrPercentage::Number(ref other)) => Ok( + SvgLengthOrPercentageOrNumber::Number(this.animate(other, procedure)?), + ), ( NumberOrPercentage::Percentage(ref this), NumberOrPercentage::Percentage(ref other), - ) => { - Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage( - LengthOrPercentage::Percentage(this.animate(other, procedure)?) - )) - }, + ) => Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage( + LengthOrPercentage::Percentage(this.animate(other, procedure)?), + )), _ => Err(()), } } @@ -73,8 +64,7 @@ impl Animate for SvgLengthOrPercentageOrNumber { impl ComputeSquaredDistance for SvgLengthOrPercentageOrNumber { fn compute_squared_distance(&self, other: &Self) -> Result { - to_number_or_percentage(self)? - .compute_squared_distance(&to_number_or_percentage(other)?) + to_number_or_percentage(self)?.compute_squared_distance(&to_number_or_percentage(other)?) } } @@ -105,9 +95,9 @@ where return Err(()); } match (self, other) { - (&SVGStrokeDashArray::Values(ref this), &SVGStrokeDashArray::Values(ref other)) => { - Ok(SVGStrokeDashArray::Values(this.animate_repeatable_list(other, procedure)?)) - }, + (&SVGStrokeDashArray::Values(ref this), &SVGStrokeDashArray::Values(ref other)) => Ok( + SVGStrokeDashArray::Values(this.animate_repeatable_list(other, procedure)?), + ), _ => Err(()), } } @@ -135,11 +125,12 @@ where #[inline] fn to_animated_zero(&self) -> Result { match *self { - SVGStrokeDashArray::Values(ref values) => { - Ok(SVGStrokeDashArray::Values( - values.iter().map(ToAnimatedZero::to_animated_zero).collect::, _>>()?, - )) - } + SVGStrokeDashArray::Values(ref values) => Ok(SVGStrokeDashArray::Values( + values + .iter() + .map(ToAnimatedZero::to_animated_zero) + .collect::, _>>()?, + )), SVGStrokeDashArray::ContextValue => Ok(SVGStrokeDashArray::ContextValue), } } diff --git a/servo/components/style/values/computed/angle.rs b/servo/components/style/values/computed/angle.rs index 1c66498f7bd3..3f697578cd51 100644 --- a/servo/components/style/values/computed/angle.rs +++ b/servo/components/style/values/computed/angle.rs @@ -5,13 +5,13 @@ //! Computed angles. use num_traits::Zero; -use std::{f32, f64}; use std::f64::consts::PI; use std::fmt::{self, Write}; use std::ops::Add; +use std::{f32, f64}; use style_traits::{CssWriter, ToCss}; -use values::CSSFloat; use values::distance::{ComputeSquaredDistance, SquaredDistance}; +use values::CSSFloat; /// A computed angle in degrees. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] @@ -92,6 +92,7 @@ impl ComputeSquaredDistance for Angle { fn compute_squared_distance(&self, other: &Self) -> Result { // Use the formula for calculating the distance between angles defined in SVG: // https://www.w3.org/TR/SVG/animate.html#complexDistances - self.radians64().compute_squared_distance(&other.radians64()) + self.radians64() + .compute_squared_distance(&other.radians64()) } } diff --git a/servo/components/style/values/computed/background.rs b/servo/components/style/values/computed/background.rs index e94bece983e5..78b9a92a9d0f 100644 --- a/servo/components/style/values/computed/background.rs +++ b/servo/components/style/values/computed/background.rs @@ -6,8 +6,8 @@ use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::computed::{Context, ToComputedValue}; use values::computed::length::NonNegativeLengthOrPercentageOrAuto; +use values::computed::{Context, ToComputedValue}; use values::generics::background::BackgroundSize as GenericBackgroundSize; use values::specified::background::BackgroundRepeat as SpecifiedBackgroundRepeat; use values::specified::background::BackgroundRepeatKeyword; diff --git a/servo/components/style/values/computed/basic_shape.rs b/servo/components/style/values/computed/basic_shape.rs index e0409a9d9042..9c6cdb66260f 100644 --- a/servo/components/style/values/computed/basic_shape.rs +++ b/servo/components/style/values/computed/basic_shape.rs @@ -9,8 +9,8 @@ use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::computed::{Image, LengthOrPercentage}; use values::computed::url::ComputedUrl; +use values::computed::{Image, LengthOrPercentage}; use values::generics::basic_shape as generic; /// A computed alias for FillRule. diff --git a/servo/components/style/values/computed/border.rs b/servo/components/style/values/computed/border.rs index 8c54aeba43bb..9a92175d9786 100644 --- a/servo/components/style/values/computed/border.rs +++ b/servo/components/style/values/computed/border.rs @@ -6,8 +6,8 @@ use app_units::Au; use values::animated::ToAnimatedZero; -use values::computed::{Number, NumberOrPercentage}; use values::computed::length::{LengthOrPercentage, NonNegativeLength}; +use values::computed::{Number, NumberOrPercentage}; use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius; use values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth; use values::generics::border::BorderImageSlice as GenericBorderImageSlice; diff --git a/servo/components/style/values/computed/box.rs b/servo/components/style/values/computed/box.rs index 002583b2c214..3e219305eff1 100644 --- a/servo/components/style/values/computed/box.rs +++ b/servo/components/style/values/computed/box.rs @@ -4,8 +4,8 @@ //! Computed types for box properties. -use values::computed::{Context, Number, ToComputedValue}; use values::computed::length::{LengthOrPercentage, NonNegativeLength}; +use values::computed::{Context, Number, ToComputedValue}; use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; use values::generics::box_::Perspective as GenericPerspective; use values::generics::box_::VerticalAlign as GenericVerticalAlign; @@ -13,7 +13,9 @@ use values::specified::box_ as specified; pub use values::specified::box_::{AnimationName, Appearance, Contain, Display, OverflowClipBox}; pub use values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; -pub use values::specified::box_::{OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange}; +pub use values::specified::box_::{ + OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange, +}; /// A computed value for the `vertical-align` property. pub type VerticalAlign = GenericVerticalAlign; diff --git a/servo/components/style/values/computed/color.rs b/servo/components/style/values/computed/color.rs index 5effffe59661..6d0713ac1d4a 100644 --- a/servo/components/style/values/computed/color.rs +++ b/servo/components/style/values/computed/color.rs @@ -7,8 +7,8 @@ use cssparser::{Color as CSSParserColor, RGBA}; use std::fmt; use style_traits::{CssWriter, ToCss}; -use values::animated::ToAnimatedValue; use values::animated::color::RGBA as AnimatedRGBA; +use values::animated::ToAnimatedValue; use values::generics::color::Color as GenericColor; /// Computed value type for the specified RGBAColor. diff --git a/servo/components/style/values/computed/effects.rs b/servo/components/style/values/computed/effects.rs index b7e8315a6ace..9a511c4fd89a 100644 --- a/servo/components/style/values/computed/effects.rs +++ b/servo/components/style/values/computed/effects.rs @@ -4,16 +4,16 @@ //! Computed types for CSS values related to effects. -#[cfg(not(feature = "gecko"))] -use values::Impossible; -use values::computed::{Angle, NonNegativeNumber}; use values::computed::color::Color; use values::computed::length::{Length, NonNegativeLength}; #[cfg(feature = "gecko")] use values::computed::url::ComputedUrl; +use values::computed::{Angle, NonNegativeNumber}; use values::generics::effects::BoxShadow as GenericBoxShadow; use values::generics::effects::Filter as GenericFilter; use values::generics::effects::SimpleShadow as GenericSimpleShadow; +#[cfg(not(feature = "gecko"))] +use values::Impossible; /// A computed value for a single shadow of the `box-shadow` property. pub type BoxShadow = GenericBoxShadow; diff --git a/servo/components/style/values/computed/font.rs b/servo/components/style/values/computed/font.rs index e83f4b3f6b87..27a8fad133d6 100644 --- a/servo/components/style/values/computed/font.rs +++ b/servo/components/style/values/computed/font.rs @@ -4,28 +4,28 @@ //! Computed values for font properties -use Atom; use app_units::Au; use byteorder::{BigEndian, ByteOrder}; use cssparser::{serialize_identifier, CssStringWriter, Parser}; #[cfg(feature = "gecko")] -use gecko_bindings::{bindings, structs}; -#[cfg(feature = "gecko")] use gecko_bindings::sugar::refptr::RefPtr; #[cfg(feature = "gecko")] +use gecko_bindings::{bindings, structs}; +#[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use std::fmt::{self, Write}; use std::hash::{Hash, Hasher}; #[cfg(feature = "servo")] use std::slice; use style_traits::{CssWriter, ParseError, ToCss}; -use values::CSSFloat; use values::animated::{ToAnimatedValue, ToAnimatedZero}; use values::computed::{Angle, Context, Integer, NonNegativeLength, NonNegativePercentage}; use values::computed::{Number, Percentage, ToComputedValue}; use values::generics::font::{self as generics, FeatureTagValue, FontSettings, VariationValue}; -use values::specified::font::{self as specified, MIN_FONT_WEIGHT, MAX_FONT_WEIGHT}; +use values::specified::font::{self as specified, MAX_FONT_WEIGHT, MIN_FONT_WEIGHT}; use values::specified::length::{FontBaseSize, NoCalcLength}; +use values::CSSFloat; +use Atom; pub use values::computed::Length as MozScriptMinSize; pub use values::specified::font::{FontSynthesis, MozScriptSizeMultiplier, XLang, XTextZoom}; diff --git a/servo/components/style/values/computed/image.rs b/servo/components/style/values/computed/image.rs index 91e55c399101..c89871f6cfb1 100644 --- a/servo/components/style/values/computed/image.rs +++ b/servo/components/style/values/computed/image.rs @@ -10,16 +10,16 @@ use std::f32::consts::PI; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::{Either, None_}; -use values::computed::{Angle, Color, Context}; -use values::computed::{Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue}; -#[cfg(feature = "gecko")] -use values::computed::Percentage; use values::computed::position::Position; use values::computed::url::ComputedImageUrl; +#[cfg(feature = "gecko")] +use values::computed::Percentage; +use values::computed::{Angle, Color, Context}; +use values::computed::{Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue}; use values::generics::image::{self as generic, CompatMode}; use values::specified::image::LineDirection as SpecifiedLineDirection; use values::specified::position::{X, Y}; +use values::{Either, None_}; /// A computed image layer. pub type ImageLayer = Either; diff --git a/servo/components/style/values/computed/length.rs b/servo/components/style/values/computed/length.rs index 83f46296f1ae..3a3242a386b5 100644 --- a/servo/components/style/values/computed/length.rs +++ b/servo/components/style/values/computed/length.rs @@ -4,20 +4,20 @@ //! `` computed values, and related ones. +use super::{Context, Number, Percentage, ToComputedValue}; use app_units::Au; use ordered_float::NotNan; use std::fmt::{self, Write}; use std::ops::{Add, Neg}; -use style_traits::{CssWriter, ToCss}; use style_traits::values::specified::AllowedNumericType; -use super::{Context, Number, Percentage, ToComputedValue}; -use values::{specified, Auto, CSSFloat, Either, Normal, IsAuto}; +use style_traits::{CssWriter, ToCss}; use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; use values::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::generics::NonNegative; use values::generics::length::{MaxLength as GenericMaxLength, MozLength as GenericMozLength}; -use values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength}; +use values::generics::NonNegative; use values::specified::length::ViewportPercentageLength; +use values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength}; +use values::{specified, Auto, CSSFloat, Either, IsAuto, Normal}; pub use super::image::Image; pub use values::specified::url::UrlOrNone; @@ -207,12 +207,12 @@ impl ToCss for CalcLengthOrPercentage { if length.px() == 0. && self.clamping_mode.clamp(p.0) == p.0 { return p.to_css(dest); } - } + }, None => { if self.clamping_mode.clamp(length.px()) == length.px() { return length.to_css(dest); } - } + }, } dest.write_str("calc(")?; @@ -957,8 +957,18 @@ pub type NonNegativeLengthOrPercentageOrNormal = Either`. pub struct Resolution(CSSFloat); diff --git a/servo/components/style/values/computed/svg.rs b/servo/components/style/values/computed/svg.rs index b41c59082ed8..dd9cfb03b4b3 100644 --- a/servo/components/style/values/computed/svg.rs +++ b/servo/components/style/values/computed/svg.rs @@ -4,11 +4,13 @@ //! Computed types for SVG properties. -use values::RGBA; -use values::computed::{NonNegativeLengthOrPercentage, NonNegativeNumber, Number, LengthOrPercentage, Opacity}; use values::computed::color::Color; use values::computed::url::ComputedUrl; +use values::computed::{ + LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber, Number, Opacity, +}; use values::generics::svg as generic; +use values::RGBA; pub use values::specified::SVGPaintOrder; @@ -51,7 +53,7 @@ impl SVGLength { /// `0px` pub fn zero() -> Self { generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::LengthOrPercentage( - LengthOrPercentage::zero() + LengthOrPercentage::zero(), )) } } @@ -84,7 +86,7 @@ impl SVGWidth { pub fn one() -> Self { use values::generics::NonNegative; generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::LengthOrPercentage( - NonNegative(LengthOrPercentage::one()) + NonNegative(LengthOrPercentage::one()), )) } } diff --git a/servo/components/style/values/computed/text.rs b/servo/components/style/values/computed/text.rs index b41ecdb7e678..f8443ec607ac 100644 --- a/servo/components/style/values/computed/text.rs +++ b/servo/components/style/values/computed/text.rs @@ -8,14 +8,14 @@ use properties::StyleBuilder; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::{CSSFloat, CSSInteger}; -use values::computed::{NonNegativeLength, NonNegativeNumber}; use values::computed::length::{Length, LengthOrPercentage}; +use values::computed::{NonNegativeLength, NonNegativeNumber}; use values::generics::text::InitialLetter as GenericInitialLetter; use values::generics::text::LineHeight as GenericLineHeight; use values::generics::text::MozTabSize as GenericMozTabSize; use values::generics::text::Spacing; use values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword, TextOverflowSide}; +use values::{CSSFloat, CSSInteger}; pub use values::specified::TextAlignKeyword as TextAlign; pub use values::specified::TextEmphasisPosition; diff --git a/servo/components/style/values/computed/transform.rs b/servo/components/style/values/computed/transform.rs index 210136427d58..e937b95c77fb 100644 --- a/servo/components/style/values/computed/transform.rs +++ b/servo/components/style/values/computed/transform.rs @@ -4,9 +4,9 @@ //! Computed types for CSS values that are related to transformations. +use super::CSSFloat; use euclid::{Transform3D, Vector3D}; use num_traits::Zero; -use super::CSSFloat; use values::animated::ToAnimatedZero; use values::computed::{Angle, Integer, Length, LengthOrPercentage, Number, Percentage}; use values::generics::transform as generic; @@ -367,9 +367,7 @@ impl Scale { pub fn to_transform_operation(&self) -> Option { match *self { generic::Scale::None => None, - generic::Scale::Scale(sx, sy) => { - Some(generic::TransformOperation::Scale(sx, Some(sy))) - }, + generic::Scale::Scale(sx, sy) => Some(generic::TransformOperation::Scale(sx, Some(sy))), generic::Scale::Scale3D(sx, sy, sz) => { Some(generic::TransformOperation::Scale3D(sx, sy, sz)) }, diff --git a/servo/components/style/values/computed/ui.rs b/servo/components/style/values/computed/ui.rs index 40f1a378cc97..cf1d953fd26f 100644 --- a/servo/components/style/values/computed/ui.rs +++ b/servo/components/style/values/computed/ui.rs @@ -4,11 +4,11 @@ //! Computed values for UI properties -use values::{Auto, Either}; -use values::computed::Number; use values::computed::color::Color; use values::computed::url::ComputedImageUrl; +use values::computed::Number; use values::generics::ui as generics; +use values::{Auto, Either}; pub use values::specified::ui::MozForceBrokenImageIcon; diff --git a/servo/components/style/values/computed/url.rs b/servo/components/style/values/computed/url.rs index cf9577101822..aca5d301fd25 100644 --- a/servo/components/style/values/computed/url.rs +++ b/servo/components/style/values/computed/url.rs @@ -6,10 +6,10 @@ use values::generics::url::UrlOrNone as GenericUrlOrNone; -#[cfg(feature = "servo")] -pub use servo::url::{ComputedImageUrl, ComputedUrl}; #[cfg(feature = "gecko")] pub use gecko::url::{ComputedImageUrl, ComputedUrl}; +#[cfg(feature = "servo")] +pub use servo::url::{ComputedImageUrl, ComputedUrl}; /// Computed | pub type UrlOrNone = GenericUrlOrNone; diff --git a/servo/components/style/values/generics/background.rs b/servo/components/style/values/generics/background.rs index 2f328eaa5e7a..e1514959837c 100644 --- a/servo/components/style/values/generics/background.rs +++ b/servo/components/style/values/generics/background.rs @@ -57,7 +57,7 @@ where height.to_css(dest)?; } Ok(()) - } + }, BackgroundSize::Cover => dest.write_str("cover"), BackgroundSize::Contain => dest.write_str("contain"), } diff --git a/servo/components/style/values/generics/basic_shape.rs b/servo/components/style/values/generics/basic_shape.rs index 513e5de0e2bd..f571d488a8e3 100644 --- a/servo/components/style/values/generics/basic_shape.rs +++ b/servo/components/style/values/generics/basic_shape.rs @@ -307,7 +307,8 @@ where this.0.animate(&other.0, procedure)?, this.1.animate(&other.1, procedure)?, )) - }).collect::, _>>()?; + }) + .collect::, _>>()?; Ok(Polygon { fill: self.fill, coordinates, @@ -333,7 +334,8 @@ where let d1 = this.0.compute_squared_distance(&other.0)?; let d2 = this.1.compute_squared_distance(&other.1)?; Ok(d1 + d2) - }).sum() + }) + .sum() } } diff --git a/servo/components/style/values/generics/counters.rs b/servo/components/style/values/generics/counters.rs index 4bbf728d457c..a5990691336d 100644 --- a/servo/components/style/values/generics/counters.rs +++ b/servo/components/style/values/generics/counters.rs @@ -7,11 +7,11 @@ #[cfg(feature = "servo")] use computed_values::list_style_type::T as ListStyleType; use std::ops::Deref; -use values::CustomIdent; #[cfg(feature = "gecko")] use values::generics::CounterStyleOrNone; #[cfg(feature = "gecko")] use values::specified::Attr; +use values::CustomIdent; /// A name / value pair for counters. #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)] diff --git a/servo/components/style/values/generics/easing.rs b/servo/components/style/values/generics/easing.rs index c4436fb2efd3..616fd63d172a 100644 --- a/servo/components/style/values/generics/easing.rs +++ b/servo/components/style/values/generics/easing.rs @@ -9,7 +9,9 @@ use parser::ParserContext; use values::CSSFloat; /// A generic easing function. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)] +#[derive( + Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, +)] #[value_info(ty = "TIMING_FUNCTION")] #[repr(u8, C)] pub enum TimingFunction { diff --git a/servo/components/style/values/generics/grid.rs b/servo/components/style/values/generics/grid.rs index 13c7fa542002..fda0c3a07594 100644 --- a/servo/components/style/values/generics/grid.rs +++ b/servo/components/style/values/generics/grid.rs @@ -7,13 +7,13 @@ use cssparser::Parser; use parser::{Parse, ParserContext}; -use std::{mem, usize}; use std::fmt::{self, Write}; +use std::{mem, usize}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use values::{CSSFloat, CustomIdent}; use values::computed::{Context, ToComputedValue}; use values::specified; use values::specified::grid::parse_line_names; +use values::{CSSFloat, CustomIdent}; /// A `` type. /// diff --git a/servo/components/style/values/generics/image.rs b/servo/components/style/values/generics/image.rs index 16d348ac47ec..9ce60d3362c3 100644 --- a/servo/components/style/values/generics/image.rs +++ b/servo/components/style/values/generics/image.rs @@ -6,12 +6,12 @@ //! //! [images]: https://drafts.csswg.org/css-images/#image-values -use Atom; use custom_properties; use servo_arc::Arc; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; use values::serialize_atom_identifier; +use Atom; /// An [image]. /// diff --git a/servo/components/style/values/generics/length.rs b/servo/components/style/values/generics/length.rs index 99976be493e4..15832b4616d6 100644 --- a/servo/components/style/values/generics/length.rs +++ b/servo/components/style/values/generics/length.rs @@ -45,7 +45,7 @@ pub enum MozLength { SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, - ToCss + ToCss, )] pub enum MaxLength { LengthOrPercentageOrNone(LengthOrPercentageOrNone), diff --git a/servo/components/style/values/generics/mod.rs b/servo/components/style/values/generics/mod.rs index 712b62679d82..0f13cfcdd2f7 100644 --- a/servo/components/style/values/generics/mod.rs +++ b/servo/components/style/values/generics/mod.rs @@ -5,12 +5,12 @@ //! Generic types that share their serialization implementations //! for both specified and computed values. +use super::CustomIdent; use counter_style::{parse_counter_style_name, Symbols}; use cssparser::Parser; use parser::{Parse, ParserContext}; use style_traits::{KeywordsCollectFn, ParseError}; use style_traits::{SpecifiedValueInfo, StyleParseErrorKind}; -use super::CustomIdent; pub mod background; pub mod basic_shape; diff --git a/servo/components/style/values/generics/transform.rs b/servo/components/style/values/generics/transform.rs index 589258e01c29..1eb46b0bd1d2 100644 --- a/servo/components/style/values/generics/transform.rs +++ b/servo/components/style/values/generics/transform.rs @@ -9,12 +9,12 @@ use euclid::{self, Rect, Transform3D}; use num_traits::Zero; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::{computed, CSSFloat}; use values::computed::length::Length as ComputedLength; use values::computed::length::LengthOrPercentage as ComputedLengthOrPercentage; use values::specified::angle::Angle as SpecifiedAngle; use values::specified::length::Length as SpecifiedLength; use values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage; +use values::{computed, CSSFloat}; /// A generic 2D transformation matrix. #[allow(missing_docs)] diff --git a/servo/components/style/values/generics/ui.rs b/servo/components/style/values/generics/ui.rs index 73f050bb12a2..c959ad73e51f 100644 --- a/servo/components/style/values/generics/ui.rs +++ b/servo/components/style/values/generics/ui.rs @@ -5,8 +5,8 @@ //! Generic values for UI properties. use std::fmt::{self, Write}; -use style_traits::{CssWriter, ToCss}; use style_traits::cursor::CursorKind; +use style_traits::{CssWriter, ToCss}; /// A generic value for the `cursor` property. /// @@ -71,8 +71,20 @@ impl ToCss for CursorImage { /// A generic value for `scrollbar-color` property. /// /// https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive( + Animate, + Clone, + ComputeSquaredDistance, + Copy, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToAnimatedValue, + ToAnimatedZero, + ToComputedValue, + ToCss, +)] pub enum ScrollbarColor { /// `auto` Auto, @@ -82,7 +94,7 @@ pub enum ScrollbarColor { thumb: Color, /// Second ``, for color of the scrollbar track. track: Color, - } + }, } impl Default for ScrollbarColor { diff --git a/servo/components/style/values/mod.rs b/servo/components/style/values/mod.rs index 73d667b83766..079b579a9882 100644 --- a/servo/components/style/values/mod.rs +++ b/servo/components/style/values/mod.rs @@ -8,19 +8,21 @@ #![deny(missing_docs)] -use Atom; -pub use cssparser::{serialize_identifier, serialize_name, CowRcStr, Parser, SourceLocation, Token, RGBA}; +pub use cssparser::{ + serialize_identifier, serialize_name, CowRcStr, Parser, SourceLocation, Token, RGBA, +}; use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use std::fmt::{self, Debug, Write}; use std::hash; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use values::distance::{ComputeSquaredDistance, SquaredDistance}; +use Atom; -#[cfg(feature = "servo")] -pub use servo::url::CssUrl; #[cfg(feature = "gecko")] pub use gecko::url::CssUrl; +#[cfg(feature = "servo")] +pub use servo::url::CssUrl; pub mod animated; pub mod computed; diff --git a/servo/components/style/values/specified/angle.rs b/servo/components/style/values/specified/angle.rs index b634756d89fb..01c86aab1801 100644 --- a/servo/components/style/values/specified/angle.rs +++ b/servo/components/style/values/specified/angle.rs @@ -9,10 +9,10 @@ use parser::{Parse, ParserContext}; use std::f32::consts::PI; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss}; -use values::CSSFloat; -use values::computed::{Context, ToComputedValue}; use values::computed::angle::Angle as ComputedAngle; +use values::computed::{Context, ToComputedValue}; use values::specified::calc::CalcNode; +use values::CSSFloat; /// A specified angle dimension. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] @@ -152,11 +152,7 @@ impl Parse for Angle { impl Angle { /// Parse an `` value given a value and an unit. - pub fn parse_dimension( - value: CSSFloat, - unit: &str, - was_calc: bool, - ) -> Result { + pub fn parse_dimension(value: CSSFloat, unit: &str, was_calc: bool) -> Result { let value = match_ignore_ascii_case! { unit, "deg" => AngleDimension::Deg(value), "grad" => AngleDimension::Grad(value), @@ -200,7 +196,8 @@ impl Angle { return input.parse_nested_block(|i| CalcNode::parse_angle(context, i)) }, _ => Err(()), - }.map_err(|()| input.new_unexpected_token_error(token.clone())) + } + .map_err(|()| input.new_unexpected_token_error(token.clone())) } } diff --git a/servo/components/style/values/specified/basic_shape.rs b/servo/components/style/values/specified/basic_shape.rs index dcf04dcc0df3..9470311b7a99 100644 --- a/servo/components/style/values/specified/basic_shape.rs +++ b/servo/components/style/values/specified/basic_shape.rs @@ -17,13 +17,13 @@ use values::generics::basic_shape as generic; use values::generics::basic_shape::{GeometryBox, Path, PolygonCoord}; use values::generics::basic_shape::{ShapeBox, ShapeSource}; use values::generics::rect::Rect; -use values::specified::LengthOrPercentage; -use values::specified::SVGPathData; use values::specified::border::BorderRadius; use values::specified::image::Image; use values::specified::position::{HorizontalPosition, Position, PositionComponent}; use values::specified::position::{Side, VerticalPosition}; use values::specified::url::SpecifiedUrl; +use values::specified::LengthOrPercentage; +use values::specified::SVGPathData; /// A specified alias for FillRule. pub use values::generics::basic_shape::FillRule; @@ -275,7 +275,8 @@ impl Ellipse { ShapeRadius::parse(context, i)?, ShapeRadius::parse(context, i)?, )) - }).unwrap_or_default(); + }) + .unwrap_or_default(); let position = if input.try(|i| i.expect_ident_matching("at")).is_ok() { Position::parse(context, input)? } else { @@ -422,7 +423,8 @@ impl Polygon { let fill = FillRule::parse(i)?; i.expect_comma()?; // only eat the comma if there is something before it Ok(fill) - }).unwrap_or_default(); + }) + .unwrap_or_default(); let buf = input.parse_comma_separated(|i| { Ok(PolygonCoord( @@ -459,7 +461,8 @@ impl Path { let fill = FillRule::parse(i)?; i.expect_comma()?; Ok(fill) - }).unwrap_or_default(); + }) + .unwrap_or_default(); let path = SVGPathData::parse(context, input)?; Ok(Path { fill, path }) } diff --git a/servo/components/style/values/specified/border.rs b/servo/components/style/values/specified/border.rs index 7a681c2ef2cf..27f403c4a289 100644 --- a/servo/components/style/values/specified/border.rs +++ b/servo/components/style/values/specified/border.rs @@ -16,8 +16,8 @@ use values::generics::border::BorderRadius as GenericBorderRadius; use values::generics::border::BorderSpacing as GenericBorderSpacing; use values::generics::rect::Rect; use values::generics::size::Size; -use values::specified::{AllowQuirks, Number, NumberOrPercentage}; use values::specified::length::{Length, LengthOrPercentage, NonNegativeLength}; +use values::specified::{AllowQuirks, Number, NumberOrPercentage}; /// A specified value for a single side of the `border-width` property. #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)] @@ -92,7 +92,8 @@ impl ToComputedValue for BorderSideWidth { BorderSideWidth::Medium => Length::from_px(3.).to_computed_value(context), BorderSideWidth::Thick => Length::from_px(5.).to_computed_value(context), BorderSideWidth::Length(ref length) => length.to_computed_value(context), - }.into() + } + .into() } #[inline] @@ -182,7 +183,8 @@ impl Parse for BorderSpacing { ) -> Result> { Size::parse_with(context, input, |context, input| { Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes).map(From::from) - }).map(GenericBorderSpacing) + }) + .map(GenericBorderSpacing) } } diff --git a/servo/components/style/values/specified/box.rs b/servo/components/style/values/specified/box.rs index 7e79fc892a5c..589d0b13d0ce 100644 --- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -4,20 +4,22 @@ //! Specified types for box properties. -use Atom; use cssparser::Parser; use custom_properties::Name as CustomPropertyName; use parser::{Parse, ParserContext}; -use properties::{LonghandId, ShorthandId, PropertyId, PropertyFlags, PropertyDeclarationId}; +use properties::{LonghandId, PropertyDeclarationId, PropertyFlags, PropertyId, ShorthandId}; use selectors::parser::SelectorParseErrorKind; use std::fmt::{self, Write}; -use style_traits::{CssWriter, KeywordsCollectFn, ParseError, StyleParseErrorKind, SpecifiedValueInfo, ToCss}; -use values::{CustomIdent, KeyframesName}; +use style_traits::{ + CssWriter, KeywordsCollectFn, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss, +}; use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; use values::generics::box_::Perspective as GenericPerspective; use values::generics::box_::VerticalAlign as GenericVerticalAlign; -use values::specified::{AllowQuirks, Number}; use values::specified::length::{LengthOrPercentage, NonNegativeLength}; +use values::specified::{AllowQuirks, Number}; +use values::{CustomIdent, KeyframesName}; +use Atom; fn in_ua_or_chrome_sheet(context: &ParserContext) -> bool { use stylesheets::Origin; diff --git a/servo/components/style/values/specified/calc.rs b/servo/components/style/values/specified/calc.rs index 3a28d42223c0..6a0f54b39261 100644 --- a/servo/components/style/values/specified/calc.rs +++ b/servo/components/style/values/specified/calc.rs @@ -9,13 +9,13 @@ use cssparser::{AngleOrNumber, NumberOrPercentage, Parser, Token}; use parser::ParserContext; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use style_traits::values::specified::AllowedNumericType; -use values::{CSSFloat, CSSInteger}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use values::computed; -use values::specified::{Angle, Time}; -use values::specified::length::{AbsoluteLength, FontRelativeLength, NoCalcLength}; use values::specified::length::ViewportPercentageLength; +use values::specified::length::{AbsoluteLength, FontRelativeLength, NoCalcLength}; +use values::specified::{Angle, Time}; +use values::{CSSFloat, CSSInteger}; /// A node inside a `Calc` expression's AST. #[derive(Clone, Debug)] @@ -529,8 +529,7 @@ impl CalcNode { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - Self::parse_number(context, input) - .map(|n| n.round() as CSSInteger) + Self::parse_number(context, input).map(|n| n.round() as CSSInteger) } /// Convenience parsing function for ` | `. diff --git a/servo/components/style/values/specified/color.rs b/servo/components/style/values/specified/color.rs index 85d29f3e7e77..cc9884525ffc 100644 --- a/servo/components/style/values/specified/color.rs +++ b/servo/components/style/values/specified/color.rs @@ -4,6 +4,7 @@ //! Specified color values. +use super::AllowQuirks; use cssparser::{AngleOrNumber, Color as CSSParserColor, Parser, Token, RGBA}; use cssparser::{BasicParseErrorKind, NumberOrPercentage, ParseErrorKind}; #[cfg(feature = "gecko")] @@ -16,7 +17,6 @@ use std::fmt::{self, Write}; use std::io::Write as IoWrite; use style_traits::{CssType, CssWriter, KeywordsCollectFn, ParseError, StyleParseErrorKind}; use style_traits::{SpecifiedValueInfo, ToCss, ValueParseErrorKind}; -use super::AllowQuirks; use values::computed::{Color as ComputedColor, Context, ToComputedValue}; use values::generics::color::Color as GenericColor; use values::specified::calc::CalcNode; diff --git a/servo/components/style/values/specified/counters.rs b/servo/components/style/values/specified/counters.rs index ce7e3991227b..d994339c5b59 100644 --- a/servo/components/style/values/specified/counters.rs +++ b/servo/components/style/values/specified/counters.rs @@ -10,17 +10,17 @@ use cssparser::{Parser, Token}; use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use style_traits::{ParseError, StyleParseErrorKind}; -use values::CustomIdent; -#[cfg(feature = "gecko")] -use values::generics::CounterStyleOrNone; use values::generics::counters as generics; use values::generics::counters::CounterIncrement as GenericCounterIncrement; use values::generics::counters::CounterPair; use values::generics::counters::CounterReset as GenericCounterReset; #[cfg(feature = "gecko")] +use values::generics::CounterStyleOrNone; +use values::specified::url::SpecifiedImageUrl; +#[cfg(feature = "gecko")] use values::specified::Attr; use values::specified::Integer; -use values::specified::url::SpecifiedImageUrl; +use values::CustomIdent; /// A specified value for the `counter-increment` property. pub type CounterIncrement = GenericCounterIncrement; @@ -93,7 +93,8 @@ impl Content { .try(|input| { input.expect_comma()?; ListStyleType::parse(input) - }).unwrap_or(ListStyleType::Decimal) + }) + .unwrap_or(ListStyleType::Decimal) } #[cfg(feature = "gecko")] @@ -102,7 +103,8 @@ impl Content { .try(|input| { input.expect_comma()?; CounterStyleOrNone::parse(context, input) - }).unwrap_or(CounterStyleOrNone::decimal()) + }) + .unwrap_or(CounterStyleOrNone::decimal()) } } diff --git a/servo/components/style/values/specified/easing.rs b/servo/components/style/values/specified/easing.rs index 017643cdab7a..ab3b4cb43bcd 100644 --- a/servo/components/style/values/specified/easing.rs +++ b/servo/components/style/values/specified/easing.rs @@ -9,8 +9,8 @@ use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use style_traits::{ParseError, StyleParseErrorKind}; use values::computed::easing::TimingFunction as ComputedTimingFunction; -use values::generics::easing::{StepPosition, TimingKeyword}; use values::generics::easing::TimingFunction as GenericTimingFunction; +use values::generics::easing::{StepPosition, TimingKeyword}; use values::specified::{Integer, Number}; /// A specified timing function. @@ -74,10 +74,9 @@ impl Parse for TimingFunction { Ok(GenericTimingFunction::Steps(steps, position)) }, _ => Err(()), - }).map_err(|()| { - location.new_custom_error( - StyleParseErrorKind::UnexpectedFunction(function.clone()) - ) + }) + .map_err(|()| { + location.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone())) }) }) } diff --git a/servo/components/style/values/specified/effects.rs b/servo/components/style/values/specified/effects.rs index 861414ca756d..3562d4fdfa4c 100644 --- a/servo/components/style/values/specified/effects.rs +++ b/servo/components/style/values/specified/effects.rs @@ -7,20 +7,20 @@ use cssparser::{self, BasicParseErrorKind, Parser, Token}; use parser::{Parse, ParserContext}; use style_traits::{ParseError, StyleParseErrorKind, ValueParseErrorKind}; -#[cfg(not(feature = "gecko"))] -use values::Impossible; -use values::computed::{Context, NonNegativeNumber as ComputedNonNegativeNumber, ToComputedValue}; use values::computed::effects::BoxShadow as ComputedBoxShadow; use values::computed::effects::SimpleShadow as ComputedSimpleShadow; -use values::generics::NonNegative; +use values::computed::{Context, NonNegativeNumber as ComputedNonNegativeNumber, ToComputedValue}; use values::generics::effects::BoxShadow as GenericBoxShadow; use values::generics::effects::Filter as GenericFilter; use values::generics::effects::SimpleShadow as GenericSimpleShadow; -use values::specified::{Angle, NumberOrPercentage}; +use values::generics::NonNegative; use values::specified::color::Color; use values::specified::length::{Length, NonNegativeLength}; #[cfg(feature = "gecko")] use values::specified::url::SpecifiedUrl; +use values::specified::{Angle, NumberOrPercentage}; +#[cfg(not(feature = "gecko"))] +use values::Impossible; /// A specified value for a single shadow of the `box-shadow` property. pub type BoxShadow = diff --git a/servo/components/style/values/specified/font.rs b/servo/components/style/values/specified/font.rs index c07bbe66f753..a2323c75c4b9 100644 --- a/servo/components/style/values/specified/font.rs +++ b/servo/components/style/values/specified/font.rs @@ -4,7 +4,6 @@ //! Specified values for font properties -use Atom; use app_units::Au; use byteorder::{BigEndian, ByteOrder}; use cssparser::{Parser, Token}; @@ -15,18 +14,21 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use parser::{Parse, ParserContext}; use properties::longhands::system_font::SystemFont; use std::fmt::{self, Write}; +use style_traits::values::SequenceWriter; use style_traits::{CssWriter, KeywordsCollectFn, ParseError}; use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss}; -use style_traits::values::SequenceWriter; -use values::CustomIdent; -use values::computed::{Angle as ComputedAngle, Percentage as ComputedPercentage}; -use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue}; use values::computed::font::{FamilyName, FontFamilyList, FontStyleAngle, SingleFontFamily}; -use values::generics::NonNegative; -use values::generics::font::{KeywordSize, VariationValue}; +use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue}; +use values::computed::{Angle as ComputedAngle, Percentage as ComputedPercentage}; use values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag}; -use values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage, NoCalcLength, Number, Percentage}; +use values::generics::font::{KeywordSize, VariationValue}; +use values::generics::NonNegative; use values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX}; +use values::specified::{ + AllowQuirks, Angle, Integer, LengthOrPercentage, NoCalcLength, Number, Percentage, +}; +use values::CustomIdent; +use Atom; // FIXME(emilio): The system font code is copy-pasta, and should be cleaned up. macro_rules! system_font_methods { @@ -733,7 +735,8 @@ impl ToComputedValue for KeywordSize { KeywordSize::XLarge => Au::from_px(FONT_MEDIUM_PX) * 3 / 2, KeywordSize::XXLarge => Au::from_px(FONT_MEDIUM_PX) * 2, KeywordSize::XXXLarge => Au::from_px(FONT_MEDIUM_PX) * 3, - }.into() + } + .into() } #[inline] @@ -837,7 +840,8 @@ impl FontSize { 6 => KeywordSize::XXLarge, // If value is greater than 7, let it be 7. _ => KeywordSize::XXXLarge, - }.into(), + } + .into(), ) } @@ -906,7 +910,8 @@ impl FontSize { .to_computed_value_zoomed( context, FontBaseSize::InheritedStyleButStripEmUnits, - ).length_component(); + ) + .length_component(); info = parent.keyword_info.map(|i| i.compose(ratio, abs.into())); } @@ -2108,7 +2113,8 @@ impl ToComputedValue for FontLanguageOverride { String::from_utf8(buf.to_vec()).unwrap() } else { unsafe { String::from_utf8_unchecked(buf.to_vec()) } - }.into_boxed_str(), + } + .into_boxed_str(), ) } } diff --git a/servo/components/style/values/specified/gecko.rs b/servo/components/style/values/specified/gecko.rs index 847d632511e7..5d9b773fd045 100644 --- a/servo/components/style/values/specified/gecko.rs +++ b/servo/components/style/values/specified/gecko.rs @@ -9,8 +9,8 @@ use gecko::values::GeckoStyleCoordConvertible; use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut}; use parser::{Parse, ParserContext}; use std::fmt; -use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use style_traits::values::SequenceWriter; +use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use values::computed; use values::computed::length::CSSPixelLength; use values::generics::gecko::ScrollSnapPoint as GenericScrollSnapPoint; diff --git a/servo/components/style/values/specified/grid.rs b/servo/components/style/values/specified/grid.rs index ec00393febdf..80b98688979f 100644 --- a/servo/components/style/values/specified/grid.rs +++ b/servo/components/style/values/specified/grid.rs @@ -9,12 +9,12 @@ use cssparser::{ParseError as CssParseError, Parser, Token}; use parser::{Parse, ParserContext}; use std::mem; use style_traits::{ParseError, StyleParseErrorKind}; -use values::{CSSFloat, CustomIdent}; use values::computed::{self, Context, ToComputedValue}; use values::generics::grid::{GridTemplateComponent, RepeatCount, TrackBreadth}; use values::generics::grid::{LineNameList, TrackKeyword, TrackRepeat, TrackSize}; use values::generics::grid::{TrackList, TrackListType, TrackListValue}; use values::specified::{Integer, LengthOrPercentage}; +use values::{CSSFloat, CustomIdent}; /// Parse a single flexible length. pub fn parse_flex<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { diff --git a/servo/components/style/values/specified/image.rs b/servo/components/style/values/specified/image.rs index 73cec6da7b1d..e515082d860d 100644 --- a/servo/components/style/values/specified/image.rs +++ b/servo/components/style/values/specified/image.rs @@ -7,8 +7,7 @@ //! //! [image]: https://drafts.csswg.org/css-images/#image-values -use Atom; -use cssparser::{Parser, Token, Delimiter}; +use cssparser::{Delimiter, Parser, Token}; use custom_properties::SpecifiedValue; use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; @@ -17,17 +16,18 @@ use servo_url::ServoUrl; use std::cmp::Ordering; use std::fmt::{self, Write}; use style_traits::{CssType, CssWriter, KeywordsCollectFn, ParseError}; -use style_traits::{StyleParseErrorKind, SpecifiedValueInfo, ToCss}; -use values::{Either, None_}; +use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss}; #[cfg(feature = "gecko")] use values::computed::{Context, Position as ComputedPosition, ToComputedValue}; -use values::generics::image::{self as generic, Circle, CompatMode, Ellipse, ShapeExtent}; use values::generics::image::PaintWorklet; +use values::generics::image::{self as generic, Circle, CompatMode, Ellipse, ShapeExtent}; use values::generics::position::Position as GenericPosition; -use values::specified::{Angle, Color, Length, LengthOrPercentage}; -use values::specified::{Number, NumberOrPercentage, Percentage}; use values::specified::position::{LegacyPosition, Position, PositionComponent, Side, X, Y}; use values::specified::url::SpecifiedImageUrl; +use values::specified::{Angle, Color, Length, LengthOrPercentage}; +use values::specified::{Number, NumberOrPercentage, Percentage}; +use values::{Either, None_}; +use Atom; /// A specified image layer. pub type ImageLayer = Either; @@ -189,7 +189,9 @@ impl Image { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - if let Ok(url) = input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input)) { + if let Ok(url) = + input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input)) + { return Ok(generic::Image::Url(url)); } Self::parse(context, input) @@ -1023,7 +1025,8 @@ impl Parse for PaintWorklet { .try(|input| { input.expect_comma()?; input.parse_comma_separated(|input| SpecifiedValue::parse(input)) - }).unwrap_or(vec![]); + }) + .unwrap_or(vec![]); Ok(PaintWorklet { name, arguments }) }) } diff --git a/servo/components/style/values/specified/length.rs b/servo/components/style/values/specified/length.rs index 4c0910681556..535cf6f65eeb 100644 --- a/servo/components/style/values/specified/length.rs +++ b/servo/components/style/values/specified/length.rs @@ -6,6 +6,7 @@ //! //! [length]: https://drafts.csswg.org/css-values/#lengths +use super::{AllowQuirks, Number, Percentage, ToComputedValue}; use app_units::Au; use cssparser::{Parser, Token}; use euclid::Size2D; @@ -13,18 +14,17 @@ use font_metrics::FontMetricsQueryResult; use parser::{Parse, ParserContext}; use std::cmp; use std::ops::{Add, Mul}; -use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind}; use style_traits::values::specified::AllowedNumericType; -use super::{AllowQuirks, Number, Percentage, ToComputedValue}; -use values::{Auto, CSSFloat, Either, Normal, IsAuto}; +use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind}; use values::computed::{self, CSSPixelLength, Context, ExtremumLength}; -use values::generics::NonNegative; use values::generics::length::{MaxLength as GenericMaxLength, MozLength as GenericMozLength}; +use values::generics::NonNegative; use values::specified::calc::CalcNode; +use values::{Auto, CSSFloat, Either, IsAuto, Normal}; -pub use values::specified::calc::CalcLengthOrPercentage; pub use super::image::{ColorStop, EndingShape as GradientEndingShape, Gradient}; pub use super::image::{GradientKind, Image}; +pub use values::specified::calc::CalcLengthOrPercentage; /// Number of app units per pixel pub const AU_PER_PX: CSSFloat = 60.; diff --git a/servo/components/style/values/specified/list.rs b/servo/components/style/values/specified/list.rs index e3a9bba218e4..3c0fb89258b9 100644 --- a/servo/components/style/values/specified/list.rs +++ b/servo/components/style/values/specified/list.rs @@ -9,9 +9,9 @@ use parser::{Parse, ParserContext}; use servo_arc::Arc; use style_traits::{ParseError, StyleParseErrorKind}; #[cfg(feature = "gecko")] -use values::CustomIdent; -#[cfg(feature = "gecko")] use values::generics::CounterStyleOrNone; +#[cfg(feature = "gecko")] +use values::CustomIdent; /// Specified and computed `list-style-type` property. #[cfg(feature = "gecko")] @@ -88,7 +88,7 @@ pub struct QuotePair { pub struct Quotes( #[css(iterable, if_empty = "none")] #[ignore_malloc_size_of = "Arc"] - pub Arc> + pub Arc>, ); impl Parse for Quotes { diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index db59ddc20abe..d96094488f6c 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -6,47 +6,51 @@ //! //! TODO(emilio): Enhance docs. -use {Atom, Namespace, Prefix}; +use super::computed::{Context, ToComputedValue}; +use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth}; +use super::generics::grid::{TrackList as GenericTrackList, TrackSize as GenericTrackSize}; +use super::generics::{GreaterThanOrEqualToOne, NonNegative}; +use super::{Auto, CSSFloat, CSSInteger, Either}; use context::QuirksMode; use cssparser::{Parser, Token}; use num_traits::One; use parser::{Parse, ParserContext}; use std::f32; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use style_traits::values::specified::AllowedNumericType; -use super::{Auto, CSSFloat, CSSInteger, Either}; -use super::computed::{Context, ToComputedValue}; -use super::generics::{GreaterThanOrEqualToOne, NonNegative}; -use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth}; -use super::generics::grid::{TrackList as GenericTrackList, TrackSize as GenericTrackSize}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use values::serialize_atom_identifier; use values::specified::calc::CalcNode; +use {Atom, Namespace, Prefix}; -pub use self::angle::Angle; #[cfg(feature = "gecko")] pub use self::align::{AlignContent, AlignItems, AlignSelf, ContentDistribution}; #[cfg(feature = "gecko")] pub use self::align::{JustifyContent, JustifyItems, JustifySelf, SelfAlignment}; +pub use self::angle::Angle; pub use self::background::{BackgroundRepeat, BackgroundSize}; pub use self::basic_shape::FillRule; pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing}; -pub use self::column::ColumnCount; -pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis, FontVariantAlternates, FontWeight}; -pub use self::font::{FontFamily, FontLanguageOverride, FontStyle, FontVariantEastAsian, FontVariationSettings}; -pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric}; -pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display}; pub use self::box_::{Appearance, Clear, Float}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; +pub use self::column::ColumnCount; pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset}; pub use self::easing::TimingFunction; pub use self::effects::{BoxShadow, Filter, SimpleShadow}; pub use self::flex::FlexBasis; +pub use self::font::{ + FontFamily, FontLanguageOverride, FontStyle, FontVariantEastAsian, FontVariationSettings, +}; +pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumeric}; +pub use self::font::{ + FontSize, FontSizeAdjust, FontStretch, FontSynthesis, FontVariantAlternates, FontWeight, +}; +pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom}; #[cfg(feature = "gecko")] pub use self::gecko::ScrollSnapPoint; pub use self::image::{ColorStop, EndingShape as GradientEndingShape, Gradient}; @@ -57,30 +61,30 @@ pub use self::length::{LengthOrPercentage, LengthOrPercentageOrAuto}; pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength}; pub use self::length::{NoCalcLength, ViewportPercentageLength}; pub use self::length::{NonNegativeLengthOrPercentage, NonNegativeLengthOrPercentageOrAuto}; -pub use self::list::{Quotes, QuotePair}; #[cfg(feature = "gecko")] pub use self::list::ListStyleType; +pub use self::list::{QuotePair, Quotes}; pub use self::motion::OffsetPath; pub use self::outline::OutlineStyle; -pub use self::rect::LengthOrNumberRect; -pub use self::resolution::Resolution; pub use self::percentage::Percentage; pub use self::position::{GridAutoFlow, GridTemplateAreas, Position}; pub use self::position::{PositionComponent, ZIndex}; +pub use self::rect::LengthOrNumberRect; +pub use self::resolution::Resolution; +pub use self::svg::MozContextProperties; pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind}; pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; -pub use self::svg::MozContextProperties; pub use self::svg_path::SVGPathData; pub use self::table::XSpan; pub use self::text::{InitialLetter, LetterSpacing, LineHeight, MozTabSize, TextAlign}; -pub use self::text::{TextEmphasisPosition, TextEmphasisStyle}; pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing}; +pub use self::text::{TextEmphasisPosition, TextEmphasisStyle}; pub use self::time::Time; pub use self::transform::{Rotate, Scale, Transform}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; -pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon}; #[cfg(feature = "gecko")] pub use self::ui::CursorImage; +pub use self::ui::{ColorOrAuto, Cursor, MozForceBrokenImageIcon}; pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent; #[cfg(feature = "gecko")] diff --git a/servo/components/style/values/specified/percentage.rs b/servo/components/style/values/specified/percentage.rs index 9f8fb1bfbf5b..55c5216fb17a 100644 --- a/servo/components/style/values/specified/percentage.rs +++ b/servo/components/style/values/specified/percentage.rs @@ -7,12 +7,12 @@ use cssparser::{Parser, Token}; use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss}; use style_traits::values::specified::AllowedNumericType; -use values::{serialize_percentage, CSSFloat}; -use values::computed::{Context, ToComputedValue}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss}; use values::computed::percentage::Percentage as ComputedPercentage; +use values::computed::{Context, ToComputedValue}; use values::specified::calc::CalcNode; +use values::{serialize_percentage, CSSFloat}; /// A percentage value. #[derive(Clone, Copy, Debug, Default, MallocSizeOf, PartialEq)] diff --git a/servo/components/style/values/specified/position.rs b/servo/components/style/values/specified/position.rs index 6117436695fd..0459d2818d8d 100644 --- a/servo/components/style/values/specified/position.rs +++ b/servo/components/style/values/specified/position.rs @@ -16,13 +16,13 @@ use std::fmt::{self, Write}; use std::ops::Range; use str::HTML_SPACE_CHARACTERS; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use values::{Either, None_}; use values::computed::{CalcLengthOrPercentage, LengthOrPercentage as ComputedLengthOrPercentage}; use values::computed::{Context, Percentage, ToComputedValue}; use values::generics::position::Position as GenericPosition; use values::generics::position::ZIndex as GenericZIndex; -use values::specified::{AllowQuirks, Integer, LengthOrPercentage}; use values::specified::transform::OriginComponent; +use values::specified::{AllowQuirks, Integer, LengthOrPercentage}; +use values::{Either, None_}; /// The specified value of a CSS `` pub type Position = GenericPosition; diff --git a/servo/components/style/values/specified/source_size_list.rs b/servo/components/style/values/specified/source_size_list.rs index 2d86d5a058f1..e00f4ee1d5d7 100644 --- a/servo/components/style/values/specified/source_size_list.rs +++ b/servo/components/style/values/specified/source_size_list.rs @@ -73,10 +73,12 @@ impl SourceSizeList { Some(ref v) => v.to_computed_value(context), None => Length::NoCalc(NoCalcLength::ViewportPercentage( ViewportPercentageLength::Vw(100.), - )).to_computed_value(context), + )) + .to_computed_value(context), }, } - }).into() + }) + .into() } } diff --git a/servo/components/style/values/specified/svg.rs b/servo/components/style/values/specified/svg.rs index f91ac511af1e..4b64e8fe5375 100644 --- a/servo/components/style/values/specified/svg.rs +++ b/servo/components/style/values/specified/svg.rs @@ -9,12 +9,12 @@ use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::{CommaWithSpace, CssWriter, ParseError, Separator}; use style_traits::{StyleParseErrorKind, ToCss}; -use values::CustomIdent; use values::generics::svg as generic; -use values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber}; -use values::specified::{Number, Opacity}; use values::specified::color::Color; use values::specified::url::SpecifiedUrl; +use values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber}; +use values::specified::{Number, Opacity}; +use values::CustomIdent; /// Specified SVG Paint value pub type SVGPaint = generic::SVGPaint; diff --git a/servo/components/style/values/specified/svg_path.rs b/servo/components/style/values/specified/svg_path.rs index 3f1fdc39d97d..02d19bffcf45 100644 --- a/servo/components/style/values/specified/svg_path.rs +++ b/servo/components/style/values/specified/svg_path.rs @@ -10,11 +10,11 @@ use std::fmt::{self, Write}; use std::iter::{Cloned, Peekable}; use std::ops::AddAssign; use std::slice; -use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use style_traits::values::SequenceWriter; -use values::CSSFloat; +use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use values::animated::{Animate, Procedure, ToAnimatedZero}; use values::distance::{ComputeSquaredDistance, SquaredDistance}; +use values::CSSFloat; /// The SVG path data. /// @@ -563,7 +563,6 @@ impl ToAnimatedZero for ArcFlag { } } - /// SVG Path parser. struct PathParser<'a> { chars: Peekable>>, diff --git a/servo/components/style/values/specified/text.rs b/servo/components/style/values/specified/text.rs index 6bd0af23eb27..32405076054e 100644 --- a/servo/components/style/values/specified/text.rs +++ b/servo/components/style/values/specified/text.rs @@ -9,22 +9,22 @@ use parser::{Parse, ParserContext}; use properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode; use selectors::parser::SelectorParseErrorKind; use std::fmt::{self, Write}; +use style_traits::values::SequenceWriter; use style_traits::{CssWriter, KeywordsCollectFn, ParseError}; use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss}; -use style_traits::values::SequenceWriter; use unicode_segmentation::UnicodeSegmentation; -use values::computed::{Context, ToComputedValue}; use values::computed::text::LineHeight as ComputedLineHeight; use values::computed::text::TextEmphasisKeywordValue as ComputedTextEmphasisKeywordValue; use values::computed::text::TextEmphasisStyle as ComputedTextEmphasisStyle; use values::computed::text::TextOverflow as ComputedTextOverflow; +use values::computed::{Context, ToComputedValue}; use values::generics::text::InitialLetter as GenericInitialLetter; use values::generics::text::LineHeight as GenericLineHeight; use values::generics::text::MozTabSize as GenericMozTabSize; use values::generics::text::Spacing; -use values::specified::{AllowQuirks, Integer, NonNegativeNumber, Number}; use values::specified::length::{FontRelativeLength, Length, LengthOrPercentage, NoCalcLength}; use values::specified::length::{NonNegativeLength, NonNegativeLengthOrPercentage}; +use values::specified::{AllowQuirks, Integer, NonNegativeNumber, Number}; /// A specified type for the `initial-letter` property. pub type InitialLetter = GenericInitialLetter; @@ -613,30 +613,40 @@ impl TextEmphasisShapeKeyword { pub fn char(&self, fill: TextEmphasisFillMode) -> &str { let fill = fill == TextEmphasisFillMode::Filled; match *self { - TextEmphasisShapeKeyword::Dot => if fill { - "\u{2022}" - } else { - "\u{25e6}" + TextEmphasisShapeKeyword::Dot => { + if fill { + "\u{2022}" + } else { + "\u{25e6}" + } }, - TextEmphasisShapeKeyword::Circle => if fill { - "\u{25cf}" - } else { - "\u{25cb}" + TextEmphasisShapeKeyword::Circle => { + if fill { + "\u{25cf}" + } else { + "\u{25cb}" + } }, - TextEmphasisShapeKeyword::DoubleCircle => if fill { - "\u{25c9}" - } else { - "\u{25ce}" + TextEmphasisShapeKeyword::DoubleCircle => { + if fill { + "\u{25c9}" + } else { + "\u{25ce}" + } }, - TextEmphasisShapeKeyword::Triangle => if fill { - "\u{25b2}" - } else { - "\u{25b3}" + TextEmphasisShapeKeyword::Triangle => { + if fill { + "\u{25b2}" + } else { + "\u{25b3}" + } }, - TextEmphasisShapeKeyword::Sesame => if fill { - "\u{fe45}" - } else { - "\u{fe46}" + TextEmphasisShapeKeyword::Sesame => { + if fill { + "\u{fe45}" + } else { + "\u{fe46}" + } }, } } diff --git a/servo/components/style/values/specified/time.rs b/servo/components/style/values/specified/time.rs index 6895a918346e..bca7c6b06365 100644 --- a/servo/components/style/values/specified/time.rs +++ b/servo/components/style/values/specified/time.rs @@ -7,12 +7,12 @@ use cssparser::{Parser, Token}; use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use style_traits::values::specified::AllowedNumericType; -use values::CSSFloat; -use values::computed::{Context, ToComputedValue}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use values::computed::time::Time as ComputedTime; +use values::computed::{Context, ToComputedValue}; use values::specified::calc::CalcNode; +use values::CSSFloat; /// A time value according to CSS-VALUES § 6.2. #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)] diff --git a/servo/components/style/values/specified/transform.rs b/servo/components/style/values/specified/transform.rs index b43e35d4dd60..d397d3d36074 100644 --- a/servo/components/style/values/specified/transform.rs +++ b/servo/components/style/values/specified/transform.rs @@ -11,8 +11,8 @@ use values::computed::{Context, LengthOrPercentage as ComputedLengthOrPercentage use values::computed::{Percentage as ComputedPercentage, ToComputedValue}; use values::generics::transform as generic; use values::generics::transform::{Matrix, Matrix3D}; -use values::specified::{self, Angle, Integer, Length, LengthOrPercentage, Number}; use values::specified::position::{Side, X, Y}; +use values::specified::{self, Angle, Integer, Length, LengthOrPercentage, Number}; pub use values::generics::transform::TransformStyle; diff --git a/servo/components/style/values/specified/ui.rs b/servo/components/style/values/specified/ui.rs index c9c5c0a84147..ec930b28c004 100644 --- a/servo/components/style/values/specified/ui.rs +++ b/servo/components/style/values/specified/ui.rs @@ -7,13 +7,13 @@ use cssparser::Parser; use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use style_traits::cursor::CursorKind; -use values::{Auto, Either}; +use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use values::generics::ui as generics; -use values::specified::Number; use values::specified::color::Color; use values::specified::url::SpecifiedImageUrl; +use values::specified::Number; +use values::{Auto, Either}; /// auto | pub type ColorOrAuto = Either; diff --git a/servo/components/style/values/specified/url.rs b/servo/components/style/values/specified/url.rs index d5a165f22d81..fe68c3143f5b 100644 --- a/servo/components/style/values/specified/url.rs +++ b/servo/components/style/values/specified/url.rs @@ -6,10 +6,10 @@ use values::generics::url::UrlOrNone as GenericUrlOrNone; -#[cfg(feature = "servo")] -pub use servo::url::{SpecifiedImageUrl, SpecifiedUrl}; #[cfg(feature = "gecko")] pub use gecko::url::{SpecifiedImageUrl, SpecifiedUrl}; +#[cfg(feature = "servo")] +pub use servo::url::{SpecifiedImageUrl, SpecifiedUrl}; /// Specified | pub type UrlOrNone = GenericUrlOrNone; diff --git a/servo/components/style_derive/cg.rs b/servo/components/style_derive/cg.rs index 6cc13c894974..fdbb96794c50 100644 --- a/servo/components/style_derive/cg.rs +++ b/servo/components/style_derive/cg.rs @@ -9,7 +9,7 @@ use syn::{GenericArgument, GenericParam, Ident, Path}; use syn::{PathArguments, PathSegment, QSelf, Type, TypeArray}; use syn::{TypeParam, TypeParen, TypePath, TypeSlice, TypeTuple}; use syn::{Variant, WherePredicate}; -use synstructure::{self, BindingInfo, BindStyle, VariantAst, VariantInfo}; +use synstructure::{self, BindStyle, BindingInfo, VariantAst, VariantInfo}; pub fn add_predicate(where_clause: &mut Option, pred: WherePredicate) { where_clause @@ -58,7 +58,8 @@ pub fn fmap_trait_output(input: &DeriveInput, trait_path: &Path, trait_output: I ) }, ref arg => panic!("arguments {:?} cannot be mapped yet", arg), - }).collect(), + }) + .collect(), colon2_token: Default::default(), gt_token: Default::default(), lt_token: Default::default(), @@ -154,14 +155,16 @@ where }) }, ref arg => panic!("arguments {:?} cannot be mapped yet", arg), - }).collect(), + }) + .collect(), ..data.clone() }) }, ref arg @ PathArguments::None => arg.clone(), ref parameters => panic!("parameters {:?} cannot be mapped yet", parameters), }, - }).collect(), + }) + .collect(), } } diff --git a/servo/components/style_derive/compute_squared_distance.rs b/servo/components/style_derive/compute_squared_distance.rs index f7e50c6bb007..a2d7cb770909 100644 --- a/servo/components/style_derive/compute_squared_distance.rs +++ b/servo/components/style_derive/compute_squared_distance.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use animate::{AnimationInputAttrs, AnimationVariantAttrs, AnimationFieldAttrs}; +use animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use cg; use quote::Tokens; use syn::{DeriveInput, Path}; diff --git a/servo/components/style_derive/to_css.rs b/servo/components/style_derive/to_css.rs index a5811471cb1d..2eafbacb548d 100644 --- a/servo/components/style_derive/to_css.rs +++ b/servo/components/style_derive/to_css.rs @@ -130,7 +130,8 @@ fn derive_variant_fields_expr( return None; } Some((binding, attrs)) - }).peekable(); + }) + .peekable(); let (first, attrs) = match iter.next() { Some(pair) => pair, diff --git a/servo/components/style_traits/values.rs b/servo/components/style_traits/values.rs index e101dd41c3ff..056f2179d28d 100644 --- a/servo/components/style_traits/values.rs +++ b/servo/components/style_traits/values.rs @@ -5,8 +5,8 @@ //! Helper types and traits for the handling of CSS values. use app_units::Au; -use cssparser::{ParseError, Parser, Token, UnicodeRange, serialize_string}; use cssparser::ToCss as CssparserToCss; +use cssparser::{serialize_string, ParseError, Parser, Token, UnicodeRange}; use servo_arc::Arc; use std::fmt::{self, Write}; diff --git a/servo/components/style_traits/viewport.rs b/servo/components/style_traits/viewport.rs index 5cf7bc956676..7b01924dd668 100644 --- a/servo/components/style_traits/viewport.rs +++ b/servo/components/style_traits/viewport.rs @@ -4,10 +4,10 @@ //! Helper types for the `@viewport` rule. -use {CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss}; use cssparser::Parser; use euclid::TypedSize2D; use std::fmt::{self, Write}; +use {CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss}; define_css_keyword_enum! { pub enum UserZoom { @@ -115,9 +115,9 @@ impl Zoom { /// /// pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { - use ParsingMode; use cssparser::Token; use values::specified::AllowedNumericType::NonNegative; + use ParsingMode; let location = input.current_source_location(); match *input.next()? {