diff options
Diffstat (limited to 'components/style')
158 files changed, 1325 insertions, 1288 deletions
diff --git a/components/style/animation.rs b/components/style/animation.rs index 14ea1e21a2d..094f3049b67 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -8,29 +8,29 @@ // compile it out so that people remember it exists, thus the cfg'd Sender // import. -use bezier::Bezier; -use context::SharedStyleContext; -use dom::{OpaqueNode, TElement}; -use font_metrics::FontMetricsProvider; -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 crate::bezier::Bezier; +use crate::context::SharedStyleContext; +use crate::dom::{OpaqueNode, TElement}; +use crate::font_metrics::FontMetricsProvider; +use crate::properties::animated_properties::AnimatedProperty; +use crate::properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection; +use crate::properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState; +use crate::properties::{self, CascadeMode, ComputedValues, LonghandId}; +use crate::rule_tree::CascadeLevel; +use crate::stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue}; +use crate::timer::Timer; +use crate::values::computed::box_::TransitionProperty; +use crate::values::computed::Time; +use crate::values::computed::TimingFunction; +use crate::values::generics::box_::AnimationIterationCount; +use crate::values::generics::easing::{StepPosition, TimingFunction as GenericTimingFunction}; +use crate::Atom; use servo_arc::Arc; #[cfg(feature = "servo")] use servo_channel::Sender; use std::fmt; #[cfg(feature = "gecko")] 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::generics::box_::AnimationIterationCount; -use values::generics::easing::{StepPosition, TimingFunction as GenericTimingFunction}; -use Atom; /// This structure represents a keyframes animation current iteration state. /// diff --git a/components/style/applicable_declarations.rs b/components/style/applicable_declarations.rs index 986dc04c371..031d0e8005b 100644 --- a/components/style/applicable_declarations.rs +++ b/components/style/applicable_declarations.rs @@ -4,10 +4,10 @@ //! Applicable declarations management. -use properties::PropertyDeclarationBlock; -use rule_tree::{CascadeLevel, ShadowCascadeOrder, StyleSource}; +use crate::properties::PropertyDeclarationBlock; +use crate::rule_tree::{CascadeLevel, ShadowCascadeOrder, StyleSource}; +use crate::shared_lock::Locked; use servo_arc::Arc; -use shared_lock::Locked; use smallvec::SmallVec; use std::fmt::{self, Debug}; diff --git a/components/style/attr.rs b/components/style/attr.rs index 158875ea327..f08ab9b42d1 100644 --- a/components/style/attr.rs +++ b/components/style/attr.rs @@ -7,20 +7,20 @@ //! [attr]: https://dom.spec.whatwg.org/#interface-attr use app_units::Au; +use crate::properties::PropertyDeclarationBlock; +use crate::shared_lock::Locked; +use crate::str::str_join; +use crate::str::{read_exponent, read_fraction, HTML_SPACE_CHARACTERS}; +use crate::str::{read_numbers, split_commas, split_html_space_chars}; +use crate::values::specified::Length; +use crate::{Atom, LocalName, Namespace, Prefix}; use cssparser::{self, Color, RGBA}; use euclid::num::Zero; use num_traits::ToPrimitive; -use properties::PropertyDeclarationBlock; use selectors::attr::AttrSelectorOperation; 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 values::specified::Length; -use {Atom, LocalName, Namespace, Prefix}; // Duplicated from script::dom::values. const UNSIGNED_LONG_MAX: u32 = 2147483647; diff --git a/components/style/author_styles.rs b/components/style/author_styles.rs index 837569078c0..3855a9d561f 100644 --- a/components/style/author_styles.rs +++ b/components/style/author_styles.rs @@ -5,16 +5,16 @@ //! A set of author stylesheets and their computed representation, such as the //! ones used for ShadowRoot and XBL. -use context::QuirksMode; -use dom::TElement; +use crate::context::QuirksMode; +use crate::dom::TElement; +use crate::invalidation::media_queries::ToMediaListKey; +use crate::media_queries::Device; +use crate::shared_lock::SharedRwLockReadGuard; +use crate::stylesheet_set::AuthorStylesheetSet; +use crate::stylesheets::StylesheetInDocument; +use crate::stylist::CascadeData; #[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; -use invalidation::media_queries::ToMediaListKey; -use media_queries::Device; -use shared_lock::SharedRwLockReadGuard; -use stylesheet_set::AuthorStylesheetSet; -use stylesheets::StylesheetInDocument; -use stylist::CascadeData; /// A set of author stylesheets and their computed representation, such as the /// ones used for ShadowRoot and XBL. diff --git a/components/style/bezier.rs b/components/style/bezier.rs index b459367b0b4..faa399656c5 100644 --- a/components/style/bezier.rs +++ b/components/style/bezier.rs @@ -8,7 +8,7 @@ #![deny(missing_docs)] -use values::CSSFloat; +use crate::values::CSSFloat; const NEWTON_METHOD_ITERATIONS: u8 = 8; diff --git a/components/style/bloom.rs b/components/style/bloom.rs index 613cbde4999..4a6c349225c 100644 --- a/components/style/bloom.rs +++ b/components/style/bloom.rs @@ -8,7 +8,7 @@ #![deny(missing_docs)] use atomic_refcell::{AtomicRefCell, AtomicRefMut}; -use dom::{SendElement, TElement}; +use crate::dom::{SendElement, TElement}; use owning_ref::OwningHandle; use selectors::bloom::BloomFilter; use servo_arc::Arc; diff --git a/components/style/context.rs b/components/style/context.rs index 822107a351d..91094b13051 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -4,29 +4,36 @@ //! The context within which style is calculated. -#[cfg(feature = "servo")] -use animation::Animation; use app_units::Au; -use bloom::StyleBloom; -use data::{EagerPseudoStyles, ElementData}; #[cfg(feature = "servo")] -use dom::OpaqueNode; -use dom::{SendElement, TElement}; +use crate::animation::Animation; +use crate::bloom::StyleBloom; +use crate::data::{EagerPseudoStyles, ElementData}; +#[cfg(feature = "servo")] +use crate::dom::OpaqueNode; +use crate::dom::{SendElement, TElement}; +use crate::font_metrics::FontMetricsProvider; +use crate::parallel::{STACK_SAFETY_MARGIN_KB, STYLE_THREAD_STACK_SIZE_KB}; +use crate::properties::ComputedValues; +#[cfg(feature = "servo")] +use crate::properties::PropertyId; +use crate::rule_cache::RuleCache; +use crate::rule_tree::StrongRuleNode; +use crate::selector_parser::{SnapshotMap, EAGER_PSEUDO_COUNT}; +use crate::shared_lock::StylesheetGuards; +use crate::sharing::StyleSharingCache; +use crate::stylist::Stylist; +use crate::thread_state::{self, ThreadState}; +use crate::timer::Timer; +use crate::traversal::DomTraversal; +use crate::traversal_flags::TraversalFlags; use euclid::Size2D; use euclid::TypedScale; -use font_metrics::FontMetricsProvider; use fxhash::FxHashMap; #[cfg(feature = "gecko")] use gecko_bindings::structs; -use parallel::{STACK_SAFETY_MARGIN_KB, STYLE_THREAD_STACK_SIZE_KB}; #[cfg(feature = "servo")] use parking_lot::RwLock; -use properties::ComputedValues; -#[cfg(feature = "servo")] -use properties::PropertyId; -use rule_cache::RuleCache; -use rule_tree::StrongRuleNode; -use selector_parser::{SnapshotMap, EAGER_PSEUDO_COUNT}; use selectors::matching::ElementSelectorFlags; use selectors::NthIndexCache; use servo_arc::Arc; @@ -34,8 +41,6 @@ use servo_arc::Arc; use servo_atoms::Atom; #[cfg(feature = "servo")] use servo_channel::Sender; -use shared_lock::StylesheetGuards; -use sharing::StyleSharingCache; use std::fmt; use std::ops; #[cfg(feature = "servo")] @@ -44,12 +49,7 @@ use style_traits::CSSPixel; use style_traits::DevicePixel; #[cfg(feature = "servo")] use style_traits::SpeculativePainter; -use stylist::Stylist; -use thread_state::{self, ThreadState}; use time; -use timer::Timer; -use traversal::DomTraversal; -use traversal_flags::TraversalFlags; use uluru::{Entry, LRUCache}; pub use selectors::matching::QuirksMode; diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs index 73bab765920..59556a04a88 100644 --- a/components/style/counter_style/mod.rs +++ b/components/style/counter_style/mod.rs @@ -6,22 +6,22 @@ //! //! [counter-style]: https://drafts.csswg.org/css-counter-styles/ +use crate::error_reporting::ContextualParseError; +use crate::parser::{Parse, ParserContext}; +use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::values::specified::Integer; +use crate::values::CustomIdent; +use crate::Atom; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser}; use cssparser::{CowRcStr, Parser, SourceLocation, Token}; -use error_reporting::ContextualParseError; -use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; -use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; use std::mem; use std::num::Wrapping; use std::ops::Range; -use str::CssStringWriter; use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError}; use style_traits::{StyleParseErrorKind, ToCss}; -use values::specified::Integer; -use values::CustomIdent; -use Atom; /// Parse a counter style name reference. /// @@ -370,7 +370,7 @@ impl Parse for System { "symbolic" => Ok(System::Symbolic), "additive" => Ok(System::Additive), "fixed" => { - let first_symbol_value = input.try(|i| Integer::parse(context, i)).ok(); + let first_symbol_value = input.r#try(|i| Integer::parse(context, i)).ok(); Ok(System::Fixed { first_symbol_value: first_symbol_value }) } "extends" => { @@ -457,7 +457,7 @@ impl Parse for Negative { ) -> Result<Self, ParseError<'i>> { Ok(Negative( Symbol::parse(context, input)?, - input.try(|input| Symbol::parse(context, input)).ok(), + input.r#try(|input| Symbol::parse(context, input)).ok(), )) } } @@ -483,7 +483,7 @@ impl Parse for Ranges { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("auto")) + .r#try(|input| input.expect_ident_matching("auto")) .is_ok() { Ok(Ranges(Vec::new())) @@ -512,7 +512,7 @@ fn parse_bound<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<CounterBound, ParseError<'i>> { - if let Ok(integer) = input.try(|input| Integer::parse(context, input)) { + if let Ok(integer) = input.r#try(|input| Integer::parse(context, input)) { return Ok(CounterBound::Integer(integer)); } input.expect_ident_matching("infinite")?; @@ -556,7 +556,7 @@ impl Parse for Pad { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - let pad_with = input.try(|input| Symbol::parse(context, input)); + let pad_with = input.r#try(|input| Symbol::parse(context, input)); let min_length = Integer::parse_non_negative(context, input)?; let pad_with = pad_with.or_else(|_| Symbol::parse(context, input))?; Ok(Pad(min_length, pad_with)) @@ -588,7 +588,7 @@ impl Parse for Symbols { ) -> Result<Self, ParseError<'i>> { let mut symbols = Vec::new(); loop { - if let Ok(s) = input.try(|input| Symbol::parse(context, input)) { + if let Ok(s) = input.r#try(|input| Symbol::parse(context, input)) { symbols.push(s) } else { if symbols.is_empty() { @@ -640,7 +640,7 @@ impl Parse for AdditiveTuple { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - let symbol = input.try(|input| Symbol::parse(context, input)); + let symbol = input.r#try(|input| Symbol::parse(context, input)); let weight = Integer::parse_non_negative(context, input)?; let symbol = symbol.or_else(|_| Symbol::parse(context, input))?; Ok(AdditiveTuple { @@ -673,7 +673,7 @@ impl Parse for SpeakAs { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let mut is_spell_out = false; - let result = input.try(|input| { + let result = input.r#try(|input| { let ident = input.expect_ident().map_err(|_| ())?; match_ignore_ascii_case! { &*ident, "auto" => Ok(SpeakAs::Auto), diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 630fb4ba116..5bd97241b67 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -6,11 +6,12 @@ //! //! [custom]: https://drafts.csswg.org/css-variables/ +use crate::hash::map::Entry; +use crate::properties::{CSSWideKeyword, CustomDeclarationValue}; +use crate::selector_map::{PrecomputedHashMap, PrecomputedHashSet}; +use crate::Atom; use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType}; -use hash::map::Entry; use precomputed_hash::PrecomputedHash; -use properties::{CSSWideKeyword, CustomDeclarationValue}; -use selector_map::{PrecomputedHashMap, PrecomputedHashSet}; use selectors::parser::SelectorParseErrorKind; use servo_arc::Arc; use smallvec::SmallVec; @@ -19,7 +20,6 @@ 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. /// @@ -553,7 +553,7 @@ fn parse_var_function<'i, 't>( let name = parse_name(&name).map_err(|()| { input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())) })?; - if input.try(|input| input.expect_comma()).is_ok() { + if input.r#try(|input| input.expect_comma()).is_ok() { parse_fallback(input)?; } if let Some(refs) = references { @@ -569,7 +569,7 @@ fn parse_env_function<'i, 't>( // TODO(emilio): This should be <custom-ident> per spec, but no other // browser does that, see https://github.com/w3c/csswg-drafts/issues/3262. input.expect_ident()?; - if input.try(|input| input.expect_comma()).is_ok() { + if input.r#try(|input| input.expect_comma()).is_ok() { parse_fallback(input)?; } if let Some(references) = references { diff --git a/components/style/data.rs b/components/style/data.rs index 4a9b0c53940..2cb46400fe9 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -4,22 +4,22 @@ //! Per-node data used in style calculation. -use context::{SharedStyleContext, StackLimitChecker}; -use dom::TElement; -use invalidation::element::invalidator::InvalidationResult; -use invalidation::element::restyle_hints::RestyleHint; +use crate::context::{SharedStyleContext, StackLimitChecker}; +use crate::dom::TElement; +use crate::invalidation::element::invalidator::InvalidationResult; +use crate::invalidation::element::restyle_hints::RestyleHint; +use crate::properties::ComputedValues; +use crate::rule_tree::StrongRuleNode; +use crate::selector_parser::{PseudoElement, RestyleDamage, EAGER_PSEUDO_COUNT}; +use crate::shared_lock::StylesheetGuards; +use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles, ResolvedStyle}; #[cfg(feature = "gecko")] use malloc_size_of::MallocSizeOfOps; -use properties::ComputedValues; -use rule_tree::StrongRuleNode; -use selector_parser::{PseudoElement, RestyleDamage, EAGER_PSEUDO_COUNT}; use selectors::NthIndexCache; use servo_arc::Arc; -use shared_lock::StylesheetGuards; use std::fmt; use std::mem; use std::ops::{Deref, DerefMut}; -use style_resolver::{PrimaryStyle, ResolvedElementStyles, ResolvedStyle}; bitflags! { /// Various flags stored on ElementData. @@ -255,8 +255,8 @@ impl ElementData { return InvalidationResult::empty(); } - use invalidation::element::invalidator::TreeStyleInvalidator; - use invalidation::element::state_and_attributes::StateAndAttrInvalidationProcessor; + use crate::invalidation::element::invalidator::TreeStyleInvalidator; + use crate::invalidation::element::state_and_attributes::StateAndAttrInvalidationProcessor; debug!( "invalidate_style_if_needed: {:?}, flags: {:?}, has_snapshot: {}, \ diff --git a/components/style/dom.rs b/components/style/dom.rs index 3d2b05de7dc..859568f2c81 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -7,30 +7,30 @@ #![allow(unsafe_code)] #![deny(missing_docs)] -use applicable_declarations::ApplicableDeclarationBlock; use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; #[cfg(feature = "gecko")] use context::PostAnimationTasks; #[cfg(feature = "gecko")] use context::UpdateAnimationsTasks; -use data::ElementData; -use element_state::ElementState; -use font_metrics::FontMetricsProvider; -use media_queries::Device; -use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock}; -use selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl}; +use crate::applicable_declarations::ApplicableDeclarationBlock; +use crate::data::ElementData; +use crate::element_state::ElementState; +use crate::font_metrics::FontMetricsProvider; +use crate::media_queries::Device; +use crate::properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock}; +use crate::selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl}; +use crate::shared_lock::Locked; +use crate::stylist::CascadeData; +use crate::traversal_flags::TraversalFlags; +use crate::{Atom, LocalName, Namespace, WeakAtom}; 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; use std::fmt::Debug; 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/components/style/dom_apis.rs b/components/style/dom_apis.rs index 371c83e7238..28c82b252e9 100644 --- a/components/style/dom_apis.rs +++ b/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 context::QuirksMode; -use dom::{TDocument, TElement, TNode, TShadowRoot}; -use invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation}; -use invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector}; +use crate::context::QuirksMode; +use crate::dom::{TDocument, TElement, TNode, TShadowRoot}; +use crate::invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation}; +use crate::invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector}; +use crate::Atom; 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; /// <https://dom.spec.whatwg.org/#dom-element-matches> pub fn element_matches<E>( @@ -594,7 +594,7 @@ pub fn query_selector<E, Q>( E: TElement, Q: SelectorQuery<E>, { - use invalidation::element::invalidator::TreeStyleInvalidator; + use crate::invalidation::element::invalidator::TreeStyleInvalidator; let quirks_mode = root.owner_doc().quirks_mode(); diff --git a/components/style/driver.rs b/components/style/driver.rs index a4ac9a75a75..76625b42006 100644 --- a/components/style/driver.rs +++ b/components/style/driver.rs @@ -7,17 +7,17 @@ #![deny(missing_docs)] -use context::{PerThreadTraversalStatistics, StyleContext}; -use context::{ThreadLocalStyleContext, TraversalStatistics}; -use dom::{SendNode, TElement, TNode}; -use parallel; -use parallel::{DispatchMode, WORK_UNIT_MAX}; +use crate::context::{PerThreadTraversalStatistics, StyleContext}; +use crate::context::{ThreadLocalStyleContext, TraversalStatistics}; +use crate::dom::{SendNode, TElement, TNode}; +use crate::parallel; +use crate::parallel::{DispatchMode, WORK_UNIT_MAX}; +use crate::scoped_tls::ScopedTLS; +use crate::traversal::{DomTraversal, PerLevelTraversalData, PreTraverseToken}; use rayon; -use scoped_tls::ScopedTLS; use std::collections::VecDeque; use std::mem; use time; -use traversal::{DomTraversal, PerLevelTraversalData, PreTraverseToken}; #[cfg(feature = "servo")] fn should_report_statistics() -> bool { diff --git a/components/style/encoding_support.rs b/components/style/encoding_support.rs index 7aec18bee2c..cf107b1f927 100644 --- a/components/style/encoding_support.rs +++ b/components/style/encoding_support.rs @@ -6,15 +6,15 @@ extern crate encoding_rs; -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::error_reporting::ParseErrorReporter; +use crate::media_queries::MediaList; +use crate::shared_lock::SharedRwLock; +use crate::stylesheets::{Origin, Stylesheet, StylesheetLoader, UrlExtraData}; use cssparser::{stylesheet_encoding, EncodingSupport}; -use error_reporting::ParseErrorReporter; -use media_queries::MediaList; use servo_arc::Arc; -use shared_lock::SharedRwLock; use std::borrow::Cow; use std::str; -use stylesheets::{Origin, Stylesheet, StylesheetLoader, UrlExtraData}; struct EncodingRs; diff --git a/components/style/error_reporting.rs b/components/style/error_reporting.rs index b5d5ba17ef8..fbd9f3f5a9b 100644 --- a/components/style/error_reporting.rs +++ b/components/style/error_reporting.rs @@ -6,10 +6,10 @@ #![deny(missing_docs)] +use crate::stylesheets::UrlExtraData; use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token}; use std::fmt; use style_traits::ParseError; -use stylesheets::UrlExtraData; /// Errors that can be encountered while parsing CSS. #[derive(Debug)] diff --git a/components/style/font_face.rs b/components/style/font_face.rs index d257aa53773..eb258ccf435 100644 --- a/components/style/font_face.rs +++ b/components/style/font_face.rs @@ -6,29 +6,29 @@ //! //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule +use crate::error_reporting::ContextualParseError; +use crate::parser::{Parse, ParserContext}; +use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::values::computed::font::FamilyName; +use crate::values::generics::font::FontStyle as GenericFontStyle; +use crate::values::specified::font::SpecifiedFontStyle; +use crate::values::specified::font::{AbsoluteFontWeight, FontStretch}; +use crate::values::specified::url::SpecifiedUrl; +use crate::values::specified::Angle; #[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")] use properties::longhands::font_language_override; 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 values::computed::font::FamilyName; -use values::generics::font::FontStyle as GenericFontStyle; -use values::specified::font::SpecifiedFontStyle; -use values::specified::font::{AbsoluteFontWeight, FontStretch}; #[cfg(feature = "gecko")] use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings}; -use values::specified::url::SpecifiedUrl; -use values::specified::Angle; /// A source for a font-face rule. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] @@ -118,7 +118,7 @@ macro_rules! impl_range { ) -> Result<Self, ParseError<'i>> { let first = $component::parse(context, input)?; let second = input - .try(|input| $component::parse(context, input)) + .r#try(|input| $component::parse(context, input)) .unwrap_or_else(|_| first.clone()); Ok($range(first, second)) } @@ -232,7 +232,7 @@ impl Parse for FontStyle { GenericFontStyle::Italic => FontStyle::Italic, GenericFontStyle::Oblique(angle) => { let second_angle = input - .try(|input| SpecifiedFontStyle::parse_angle(context, input)) + .r#try(|input| SpecifiedFontStyle::parse_angle(context, input)) .unwrap_or_else(|_| angle.clone()); FontStyle::Oblique(angle, second_angle) @@ -378,7 +378,7 @@ impl Parse for Source { input: &mut Parser<'i, 't>, ) -> Result<Source, ParseError<'i>> { if input - .try(|input| input.expect_function_matching("local")) + .r#try(|input| input.expect_function_matching("local")) .is_ok() { return input @@ -390,7 +390,7 @@ impl Parse for Source { // Parsing optional format() let format_hints = if input - .try(|input| input.expect_function_matching("format")) + .r#try(|input| input.expect_function_matching("format")) .is_ok() { input.parse_nested_block(|input| { diff --git a/components/style/font_metrics.rs b/components/style/font_metrics.rs index e093f13ef18..21c89fe06f0 100644 --- a/components/style/font_metrics.rs +++ b/components/style/font_metrics.rs @@ -7,11 +7,11 @@ #![deny(missing_docs)] use app_units::Au; -use context::SharedStyleContext; -use logical_geometry::WritingMode; -use media_queries::Device; -use properties::style_structs::Font; -use Atom; +use crate::context::SharedStyleContext; +use crate::logical_geometry::WritingMode; +use crate::media_queries::Device; +use crate::properties::style_structs::Font; +use crate::Atom; /// Represents the font metrics that style needs from a font to compute the /// value of certain CSS units like `ex`. diff --git a/components/style/invalidation/element/document_state.rs b/components/style/invalidation/element/document_state.rs index efff013069a..1ae2a97cb51 100644 --- a/components/style/invalidation/element/document_state.rs +++ b/components/style/invalidation/element/document_state.rs @@ -4,13 +4,13 @@ //! An invalidation processor for style changes due to document state changes. -use dom::TElement; -use element_state::DocumentState; -use invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; -use invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; -use invalidation::element::state_and_attributes; +use crate::dom::TElement; +use crate::element_state::DocumentState; +use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; +use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; +use crate::invalidation::element::state_and_attributes; +use crate::stylist::CascadeData; use selectors::matching::{MatchingContext, MatchingMode, QuirksMode, VisitedHandlingMode}; -use stylist::CascadeData; /// A struct holding the members necessary to invalidate document state /// selectors. diff --git a/components/style/invalidation/element/element_wrapper.rs b/components/style/invalidation/element/element_wrapper.rs index 457c8238abc..167b995d524 100644 --- a/components/style/invalidation/element/element_wrapper.rs +++ b/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 dom::TElement; -use element_state::ElementState; -use selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl}; -use selector_parser::{Snapshot, SnapshotMap}; +use crate::dom::TElement; +use crate::element_state::ElementState; +use crate::selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl}; +use crate::selector_parser::{Snapshot, SnapshotMap}; +use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, WeakAtom}; 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 @@ -60,7 +60,7 @@ pub trait ElementSnapshot: Sized { /// A callback that should be called for each class of the snapshot. Should /// only be called if `has_attrs()` returns true. - fn each_class<F>(&self, F) + fn each_class<F>(&self, _: F) where F: FnMut(&Atom); diff --git a/components/style/invalidation/element/invalidation_map.rs b/components/style/invalidation/element/invalidation_map.rs index adc6783a272..60a17a77bd0 100644 --- a/components/style/invalidation/element/invalidation_map.rs +++ b/components/style/invalidation/element/invalidation_map.rs @@ -4,18 +4,18 @@ //! Code for invalidations due to state or attribute changes. -use context::QuirksMode; -use element_state::{DocumentState, ElementState}; +use crate::context::QuirksMode; +use crate::element_state::{DocumentState, ElementState}; +use crate::selector_map::{MaybeCaseInsensitiveHashMap, SelectorMap, SelectorMapEntry}; +use crate::selector_parser::SelectorImpl; +use crate::{Atom, LocalName, Namespace}; use fallible::FallibleVec; use hashglobe::FailedAllocationError; -use selector_map::{MaybeCaseInsensitiveHashMap, SelectorMap, SelectorMapEntry}; -use selector_parser::SelectorImpl; use selectors::attr::NamespaceConstraint; 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/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 4a38c0ef931..ad07113f1e7 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -5,9 +5,9 @@ //! The struct that takes care of encapsulating all the logic on where and how //! element styles need to be invalidated. -use context::StackLimitChecker; -use dom::{TElement, TNode, TShadowRoot}; -use selector_parser::SelectorImpl; +use crate::context::StackLimitChecker; +use crate::dom::{TElement, TNode, TShadowRoot}; +use crate::selector_parser::SelectorImpl; use selectors::matching::matches_compound_selector_from; use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext}; use selectors::parser::{Combinator, Component, Selector}; diff --git a/components/style/invalidation/element/restyle_hints.rs b/components/style/invalidation/element/restyle_hints.rs index 18e2f96470a..a17c8b3d5b1 100644 --- a/components/style/invalidation/element/restyle_hints.rs +++ b/components/style/invalidation/element/restyle_hints.rs @@ -4,9 +4,9 @@ //! Restyle hints: an optimization to avoid unnecessarily matching selectors. +use crate::traversal_flags::TraversalFlags; #[cfg(feature = "gecko")] use gecko_bindings::structs::nsRestyleHint; -use traversal_flags::TraversalFlags; bitflags! { /// The kind of restyle we need to do for a given element. diff --git a/components/style/invalidation/element/state_and_attributes.rs b/components/style/invalidation/element/state_and_attributes.rs index 1de675d396e..8befd646d8c 100644 --- a/components/style/invalidation/element/state_and_attributes.rs +++ b/components/style/invalidation/element/state_and_attributes.rs @@ -5,24 +5,24 @@ //! An invalidation processor for style changes due to state and attribute //! changes. -use context::SharedStyleContext; -use data::ElementData; -use dom::TElement; -use element_state::ElementState; -use invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; -use invalidation::element::invalidation_map::*; -use invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; -use invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; -use invalidation::element::restyle_hints::RestyleHint; -use selector_map::SelectorMap; -use selector_parser::Snapshot; +use crate::context::SharedStyleContext; +use crate::data::ElementData; +use crate::dom::TElement; +use crate::element_state::ElementState; +use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; +use crate::invalidation::element::invalidation_map::*; +use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; +use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; +use crate::invalidation::element::restyle_hints::RestyleHint; +use crate::selector_map::SelectorMap; +use crate::selector_parser::Snapshot; +use crate::stylesheets::origin::{Origin, OriginSet}; +use crate::{Atom, WeakAtom}; use selectors::attr::CaseSensitivity; 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/components/style/invalidation/media_queries.rs b/components/style/invalidation/media_queries.rs index 879540d683f..5a24cf7695a 100644 --- a/components/style/invalidation/media_queries.rs +++ b/components/style/invalidation/media_queries.rs @@ -4,12 +4,12 @@ //! Code related to the invalidation of media-query-affected rules. -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::media_queries::Device; +use crate::shared_lock::SharedRwLockReadGuard; +use crate::stylesheets::{DocumentRule, ImportRule, MediaRule}; +use crate::stylesheets::{NestedRuleIterationCondition, Stylesheet, SupportsRule}; use fxhash::FxHashSet; -use media_queries::Device; -use shared_lock::SharedRwLockReadGuard; -use stylesheets::{DocumentRule, ImportRule, MediaRule}; -use stylesheets::{NestedRuleIterationCondition, Stylesheet, SupportsRule}; /// A key for a given media query result. /// @@ -115,7 +115,7 @@ impl NestedRuleIterationCondition for PotentiallyEffectiveMediaRules { quirks_mode: QuirksMode, rule: &DocumentRule, ) -> bool { - use stylesheets::EffectiveRules; + use crate::stylesheets::EffectiveRules; EffectiveRules::process_document(guard, device, quirks_mode, rule) } @@ -126,7 +126,7 @@ impl NestedRuleIterationCondition for PotentiallyEffectiveMediaRules { quirks_mode: QuirksMode, rule: &SupportsRule, ) -> bool { - use stylesheets::EffectiveRules; + use crate::stylesheets::EffectiveRules; EffectiveRules::process_supports(guard, device, quirks_mode, rule) } } diff --git a/components/style/invalidation/stylesheets.rs b/components/style/invalidation/stylesheets.rs index fac9428bc75..cbdcd2b2af8 100644 --- a/components/style/invalidation/stylesheets.rs +++ b/components/style/invalidation/stylesheets.rs @@ -7,19 +7,19 @@ #![deny(unsafe_code)] -use dom::{TDocument, TElement, TNode}; +use crate::dom::{TDocument, TElement, TNode}; +use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; +use crate::invalidation::element::restyle_hints::RestyleHint; +use crate::media_queries::Device; +use crate::selector_parser::{SelectorImpl, Snapshot, SnapshotMap}; +use crate::shared_lock::SharedRwLockReadGuard; +use crate::stylesheets::{CssRule, StylesheetInDocument}; +use crate::Atom; +use crate::CaseSensitivityExt; +use crate::LocalName as SelectorLocalName; use fxhash::FxHashSet; -use invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; -use invalidation::element::restyle_hints::RestyleHint; -use media_queries::Device; -use selector_parser::{SelectorImpl, Snapshot, SnapshotMap}; 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 @@ -419,7 +419,7 @@ impl StylesheetInvalidationSet { guard: &SharedRwLockReadGuard, device: &Device, ) { - use stylesheets::CssRule::*; + use crate::stylesheets::CssRule::*; debug!("StylesheetInvalidationSet::collect_invalidations_for_rule"); debug_assert!(!self.fully_invalid, "Not worth to be here!"); diff --git a/components/style/lib.rs b/components/style/lib.rs index 29df16f6183..ecf066fb431 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -215,10 +215,10 @@ macro_rules! reexport_computed_values { /// [computed]: https://drafts.csswg.org/css-cascade/#computed pub mod computed_values { $( - pub use properties::longhands::$name::computed_value as $name; + pub use crate::properties::longhands::$name::computed_value as $name; )+ // Don't use a side-specific name needlessly: - pub use properties::longhands::border_top_style::computed_value as border_style; + pub use crate::properties::longhands::border_top_style::computed_value as border_style; } } } diff --git a/components/style/logical_geometry.rs b/components/style/logical_geometry.rs index cae71229bbd..7ea5b409a5b 100644 --- a/components/style/logical_geometry.rs +++ b/components/style/logical_geometry.rs @@ -4,9 +4,9 @@ //! Geometry in flow-relative space. +use crate::properties::style_structs; 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}; use std::ops::{Add, Sub}; @@ -42,8 +42,8 @@ bitflags!( impl WritingMode { /// Return a WritingMode bitflags from the relevant CSS properties. pub fn new(inheritedbox_style: &style_structs::InheritedBox) -> Self { - use properties::longhands::direction::computed_value::T as Direction; - use properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode; + use crate::properties::longhands::direction::computed_value::T as Direction; + use crate::properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode; let mut flags = WritingMode::empty(); diff --git a/components/style/matching.rs b/components/style/matching.rs index 1b0f14feb56..f8aac1ac962 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -7,19 +7,19 @@ #![allow(unsafe_code)] #![deny(missing_docs)] -use context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap}; -use context::{SharedStyleContext, StyleContext}; -use data::ElementData; -use dom::TElement; -use invalidation::element::restyle_hints::RestyleHint; -use properties::longhands::display::computed_value::T as Display; -use properties::ComputedValues; -use rule_tree::{CascadeLevel, StrongRuleNode}; -use selector_parser::{PseudoElement, RestyleDamage}; +use crate::context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap}; +use crate::context::{SharedStyleContext, StyleContext}; +use crate::data::ElementData; +use crate::dom::TElement; +use crate::invalidation::element::restyle_hints::RestyleHint; +use crate::properties::longhands::display::computed_value::T as Display; +use crate::properties::ComputedValues; +use crate::rule_tree::{CascadeLevel, StrongRuleNode}; +use crate::selector_parser::{PseudoElement, RestyleDamage}; +use crate::style_resolver::ResolvedElementStyles; +use crate::traversal_flags::TraversalFlags; use selectors::matching::ElementSelectorFlags; use servo_arc::{Arc, ArcBorrow}; -use style_resolver::ResolvedElementStyles; -use traversal_flags::TraversalFlags; /// Represents the result of comparing an element's old and new style. #[derive(Debug)] @@ -93,8 +93,8 @@ trait PrivateMatchMethods: TElement { cascade_visited: CascadeVisitedMode, cascade_inputs: &mut ElementCascadeInputs, ) -> bool { - use properties::PropertyDeclarationBlock; - use shared_lock::Locked; + use crate::properties::PropertyDeclarationBlock; + use crate::shared_lock::Locked; debug_assert!( replacements.intersects(RestyleHint::replacements()) && @@ -419,8 +419,8 @@ trait PrivateMatchMethods: TElement { _restyle_hint: RestyleHint, _important_rules_changed: bool, ) { - use animation; - use dom::TNode; + use crate::animation; + use crate::dom::TNode; let mut possibly_expired_animations = vec![]; let shared_context = context.shared; @@ -583,11 +583,11 @@ trait PrivateMatchMethods: TElement { &self, context: &SharedStyleContext, style: &mut Arc<ComputedValues>, - possibly_expired_animations: &mut Vec<::animation::PropertyAnimation>, - font_metrics: &::font_metrics::FontMetricsProvider, + possibly_expired_animations: &mut Vec<crate::animation::PropertyAnimation>, + font_metrics: &crate::font_metrics::FontMetricsProvider, ) { - use animation::{self, Animation, AnimationUpdate}; - use dom::TNode; + use crate::animation::{self, Animation, AnimationUpdate}; + use crate::dom::TNode; // Finish any expired transitions. let this_opaque = self.as_node().opaque(); diff --git a/components/style/media_queries/media_condition.rs b/components/style/media_queries/media_condition.rs index af2d5a3be69..c0b8f49b566 100644 --- a/components/style/media_queries/media_condition.rs +++ b/components/style/media_queries/media_condition.rs @@ -7,9 +7,9 @@ //! https://drafts.csswg.org/mediaqueries-4/#typedef-media-condition use super::{Device, MediaFeatureExpression}; -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::parser::ParserContext; use cssparser::{Parser, Token}; -use parser::ParserContext; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; @@ -114,7 +114,7 @@ impl MediaCondition { // ParenthesisBlock. let first_condition = Self::parse_paren_block(context, input)?; - let operator = match input.try(Operator::parse) { + let operator = match input.r#try(Operator::parse) { Ok(op) => op, Err(..) => return Ok(first_condition), }; @@ -133,7 +133,7 @@ impl MediaCondition { }; loop { - if input.try(|i| i.expect_ident_matching(delim)).is_err() { + if input.r#try(|i| i.expect_ident_matching(delim)).is_err() { return Ok(MediaCondition::Operation( conditions.into_boxed_slice(), operator, @@ -159,7 +159,7 @@ impl MediaCondition { ) -> Result<Self, ParseError<'i>> { input.parse_nested_block(|input| { // Base case. - if let Ok(inner) = input.try(|i| Self::parse(context, i)) { + if let Ok(inner) = input.r#try(|i| Self::parse(context, i)) { return Ok(MediaCondition::InParens(Box::new(inner))); } let expr = MediaFeatureExpression::parse_in_parenthesis_block(context, input)?; diff --git a/components/style/media_queries/media_feature.rs b/components/style/media_queries/media_feature.rs index 84a13c06f63..7a1b67ab08c 100644 --- a/components/style/media_queries/media_feature.rs +++ b/components/style/media_queries/media_feature.rs @@ -6,12 +6,12 @@ use super::media_feature_expression::{AspectRatio, RangeOrOperator}; use super::Device; +use crate::parser::ParserContext; +use crate::values::computed::{CSSPixelLength, Resolution}; +use crate::Atom; use cssparser::Parser; -use parser::ParserContext; use std::fmt; use style_traits::ParseError; -use values::computed::{CSSPixelLength, Resolution}; -use Atom; /// A generic discriminant for an enum value. pub type KeywordDiscriminant = u8; diff --git a/components/style/media_queries/media_feature_expression.rs b/components/style/media_queries/media_feature_expression.rs index 52292e9571b..751fb5b43a1 100644 --- a/components/style/media_queries/media_feature_expression.rs +++ b/components/style/media_queries/media_feature_expression.rs @@ -8,21 +8,21 @@ use super::media_feature::{Evaluator, MediaFeatureDescription}; use super::media_feature::{KeywordDiscriminant, ParsingRequirements}; use super::Device; -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::parser::{Parse, ParserContext}; +use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase}; +use crate::stylesheets::Origin; +use crate::values::computed::{self, ToComputedValue}; +use crate::values::specified::{Integer, Length, Number, Resolution}; +use crate::values::{serialize_atom_identifier, CSSFloat}; +use crate::Atom; use cssparser::{Parser, Token}; #[cfg(feature = "gecko")] use gecko_bindings::structs; use num_traits::Zero; -use parser::{Parse, ParserContext}; 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 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)] @@ -221,14 +221,14 @@ fn consume_operation_or_colon(input: &mut Parser) -> Result<Option<Operator>, () Ok(Some(match first_delim { '=' => Operator::Equal, '>' => { - if input.try(|i| i.expect_delim('=')).is_ok() { + if input.r#try(|i| i.expect_delim('=')).is_ok() { Operator::GreaterThanEqual } else { Operator::GreaterThan } }, '<' => { - if input.try(|i| i.expect_delim('=')).is_ok() { + if input.r#try(|i| i.expect_delim('=')).is_ok() { Operator::LessThanEqual } else { Operator::LessThan @@ -270,10 +270,10 @@ impl MediaFeatureExpression { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { + #[cfg(feature = "servo")] + use crate::servo::media_queries::MEDIA_FEATURES; #[cfg(feature = "gecko")] use gecko::media_features::MEDIA_FEATURES; - #[cfg(feature = "servo")] - use servo::media_queries::MEDIA_FEATURES; // FIXME: remove extra indented block when lifetimes are non-lexical let feature; @@ -350,7 +350,7 @@ impl MediaFeatureExpression { } } - let operator = input.try(consume_operation_or_colon); + let operator = input.r#try(consume_operation_or_colon); let operator = match operator { Err(..) => { // If there's no colon, this is a media query of the diff --git a/components/style/media_queries/media_list.rs b/components/style/media_queries/media_list.rs index 302b3db6999..49c71ba0783 100644 --- a/components/style/media_queries/media_list.rs +++ b/components/style/media_queries/media_list.rs @@ -7,11 +7,11 @@ //! https://drafts.csswg.org/mediaqueries/#typedef-media-query-list use super::{Device, MediaQuery, Qualifier}; -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::error_reporting::ContextualParseError; +use crate::parser::ParserContext; use cssparser::{Delimiter, Parser}; use cssparser::{ParserInput, Token}; -use error_reporting::ContextualParseError; -use parser::ParserContext; /// A type that encapsulates a media query list. #[css(comma, derive_debug)] diff --git a/components/style/media_queries/media_query.rs b/components/style/media_queries/media_query.rs index 5875b5b38ea..61e2e06c573 100644 --- a/components/style/media_queries/media_query.rs +++ b/components/style/media_queries/media_query.rs @@ -7,13 +7,13 @@ //! https://drafts.csswg.org/mediaqueries/#typedef-media-query use super::media_condition::MediaCondition; +use crate::parser::ParserContext; +use crate::str::string_as_ascii_lowercase; +use crate::values::CustomIdent; +use crate::Atom; use cssparser::Parser; -use parser::ParserContext; use std::fmt::{self, Write}; -use str::string_as_ascii_lowercase; use style_traits::{CssWriter, ParseError, ToCss}; -use values::CustomIdent; -use Atom; /// <https://drafts.csswg.org/mediaqueries/#mq-prefix> #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)] @@ -125,8 +125,8 @@ impl MediaQuery { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let (qualifier, explicit_media_type) = input - .try(|input| -> Result<_, ()> { - let qualifier = input.try(Qualifier::parse).ok(); + .r#try(|input| -> Result<_, ()> { + let qualifier = input.r#try(Qualifier::parse).ok(); let ident = input.expect_ident().map_err(|_| ())?; let media_type = MediaQueryType::parse(&ident)?; Ok((qualifier, Some(media_type))) @@ -135,7 +135,7 @@ impl MediaQuery { let condition = if explicit_media_type.is_none() { Some(MediaCondition::parse(context, input)?) - } else if input.try(|i| i.expect_ident_matching("and")).is_ok() { + } else if input.r#try(|i| i.expect_ident_matching("and")).is_ok() { Some(MediaCondition::parse_disallow_or(context, input)?) } else { None diff --git a/components/style/media_queries/mod.rs b/components/style/media_queries/mod.rs index 93a5abf3b01..f7f985b4f9d 100644 --- a/components/style/media_queries/mod.rs +++ b/components/style/media_queries/mod.rs @@ -18,7 +18,7 @@ pub use self::media_feature_expression::MediaFeatureExpression; pub use self::media_list::MediaList; pub use self::media_query::{MediaQuery, MediaQueryType, MediaType, Qualifier}; +#[cfg(feature = "servo")] +pub use crate::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/components/style/parallel.rs b/components/style/parallel.rs index 25aaed5f3a3..5753320ca21 100644 --- a/components/style/parallel.rs +++ b/components/style/parallel.rs @@ -23,13 +23,13 @@ #![deny(missing_docs)] use arrayvec::ArrayVec; -use context::{StyleContext, ThreadLocalStyleContext}; -use dom::{OpaqueNode, SendNode, TElement}; +use crate::context::{StyleContext, ThreadLocalStyleContext}; +use crate::dom::{OpaqueNode, SendNode, TElement}; +use crate::scoped_tls::ScopedTLS; +use crate::traversal::{DomTraversal, PerLevelTraversalData}; use itertools::Itertools; use rayon; -use scoped_tls::ScopedTLS; use smallvec::SmallVec; -use traversal::{DomTraversal, PerLevelTraversalData}; /// The minimum stack size for a thread in the styling pool, in kilobytes. pub const STYLE_THREAD_STACK_SIZE_KB: usize = 256; diff --git a/components/style/parser.rs b/components/style/parser.rs index 2d667f3f343..0e82b06ab3e 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -4,12 +4,12 @@ //! The context within which CSS code is parsed. -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::error_reporting::{ContextualParseError, ParseErrorReporter}; +use crate::stylesheets::{CssRuleType, Namespaces, Origin, UrlExtraData}; +use crate::use_counters::UseCounters; use cssparser::{Parser, SourceLocation, UnicodeRange}; -use error_reporting::{ContextualParseError, ParseErrorReporter}; use style_traits::{OneOrMoreSeparated, ParseError, ParsingMode, Separator}; -use stylesheets::{CssRuleType, Namespaces, Origin, UrlExtraData}; -use use_counters::UseCounters; /// Asserts that all ParsingMode flags have a matching ParsingMode value in gecko. #[cfg(feature = "gecko")] diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index c37a4327e9f..13d9fa87fd1 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -4,27 +4,27 @@ //! The main cascading algorithm of the style system. -use context::QuirksMode; -use custom_properties::CustomPropertiesBuilder; -use dom::TElement; -use font_metrics::FontMetricsProvider; -use logical_geometry::WritingMode; -use media_queries::Device; -use properties::{ComputedValues, StyleBuilder}; -use properties::{LonghandId, LonghandIdSet}; -use properties::{PropertyDeclaration, PropertyDeclarationId, DeclarationImportanceIterator}; -use properties::CASCADE_PROPERTY; -use rule_cache::{RuleCache, RuleCacheConditions}; -use rule_tree::{CascadeLevel, StrongRuleNode}; -use selector_parser::PseudoElement; +use crate::context::QuirksMode; +use crate::custom_properties::CustomPropertiesBuilder; +use crate::dom::TElement; +use crate::font_metrics::FontMetricsProvider; +use crate::logical_geometry::WritingMode; +use crate::media_queries::Device; +use crate::properties::{ComputedValues, StyleBuilder}; +use crate::properties::{LonghandId, LonghandIdSet}; +use crate::properties::{PropertyDeclaration, PropertyDeclarationId, DeclarationImportanceIterator}; +use crate::properties::CASCADE_PROPERTY; +use crate::rule_cache::{RuleCache, RuleCacheConditions}; +use crate::rule_tree::{CascadeLevel, StrongRuleNode}; +use crate::selector_parser::PseudoElement; use servo_arc::Arc; -use shared_lock::StylesheetGuards; +use crate::shared_lock::StylesheetGuards; use smallbitvec::SmallBitVec; use smallvec::SmallVec; use std::borrow::Cow; use std::cell::RefCell; -use style_adjuster::StyleAdjuster; -use values::computed; +use crate::style_adjuster::StyleAdjuster; +use crate::values::computed; /// We split the cascade in two phases: 'early' properties, and 'late' /// properties. diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 99dee046112..a6d736fb49f 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -6,25 +6,25 @@ #![deny(missing_docs)] -use context::QuirksMode; +use crate::context::QuirksMode; use cssparser::{DeclarationListParser, parse_important, ParserInput, CowRcStr}; use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter, ParseErrorKind}; -use custom_properties::{CustomPropertiesBuilder, CssEnvironment}; -use error_reporting::{ParseErrorReporter, ContextualParseError}; +use crate::custom_properties::{CustomPropertiesBuilder, CssEnvironment}; +use crate::error_reporting::{ParseErrorReporter, ContextualParseError}; use itertools::Itertools; -use parser::ParserContext; -use properties::animated_properties::{AnimationValue, AnimationValueMap}; -use shared_lock::Locked; +use crate::parser::ParserContext; +use crate::properties::animated_properties::{AnimationValue, AnimationValueMap}; +use crate::shared_lock::Locked; use smallbitvec::{self, SmallBitVec}; use smallvec::SmallVec; use std::fmt::{self, Write}; use std::iter::{DoubleEndedIterator, Zip}; use std::slice::Iter; -use str::{CssString, CssStringBorrow, CssStringWriter}; +use crate::str::{CssString, CssStringBorrow, CssStringWriter}; use style_traits::{CssWriter, ParseError, ParsingMode, StyleParseErrorKind, ToCss}; -use stylesheets::{CssRuleType, Origin, UrlExtraData}; +use crate::stylesheets::{CssRuleType, Origin, UrlExtraData}; use super::*; -use values::computed::Context; +use crate::values::computed::Context; /// The animation rules. /// @@ -144,7 +144,7 @@ pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> { context: &'cx mut Context<'cx_a>, default_values: &'a ComputedValues, /// Custom properties in a keyframe if exists. - extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, + extra_custom_properties: Option<&'a Arc<crate::custom_properties::CustomPropertiesMap>>, } impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> { @@ -152,7 +152,7 @@ impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> { declarations: &'a PropertyDeclarationBlock, context: &'cx mut Context<'cx_a>, default_values: &'a ComputedValues, - extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, + extra_custom_properties: Option<&'a Arc<crate::custom_properties::CustomPropertiesMap>>, ) -> AnimationValueIterator<'a, 'cx, 'cx_a> { AnimationValueIterator { iter: declarations.declaration_importance_iter(), @@ -258,7 +258,7 @@ impl PropertyDeclarationBlock { &'a self, context: &'cx mut Context<'cx_a>, default_values: &'a ComputedValues, - extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, + extra_custom_properties: Option<&'a Arc<crate::custom_properties::CustomPropertiesMap>>, ) -> AnimationValueIterator<'a, 'cx, 'cx_a> { AnimationValueIterator::new(self, context, default_values, extra_custom_properties) } @@ -467,7 +467,7 @@ impl PropertyDeclarationBlock { // // TODO(emilio): Unship. if let PropertyDeclaration::Display(old_display) = *slot { - use properties::longhands::display::computed_value::T as display; + use crate::properties::longhands::display::computed_value::T as display; if let PropertyDeclaration::Display(new_display) = declaration { if display::should_ignore_parsed_value(old_display, new_display) { @@ -841,7 +841,7 @@ impl PropertyDeclarationBlock { pub fn cascade_custom_properties_with_context( &self, context: &Context, - ) -> Option<Arc<::custom_properties::CustomPropertiesMap>> { + ) -> Option<Arc<crate::custom_properties::CustomPropertiesMap>> { self.cascade_custom_properties( context.style().custom_properties(), context.device().environment(), @@ -853,9 +853,9 @@ impl PropertyDeclarationBlock { /// properties. fn cascade_custom_properties( &self, - inherited_custom_properties: Option<&Arc<::custom_properties::CustomPropertiesMap>>, + inherited_custom_properties: Option<&Arc<crate::custom_properties::CustomPropertiesMap>>, environment: &CssEnvironment, - ) -> Option<Arc<::custom_properties::CustomPropertiesMap>> { + ) -> Option<Arc<crate::custom_properties::CustomPropertiesMap>> { let mut builder = CustomPropertiesBuilder::new( inherited_custom_properties, environment, diff --git a/components/style/rule_cache.rs b/components/style/rule_cache.rs index 5e386d711cb..709d3ec5727 100644 --- a/components/style/rule_cache.rs +++ b/components/style/rule_cache.rs @@ -5,15 +5,15 @@ //! A cache from rule node to computed values, in order to cache reset //! properties. +use crate::logical_geometry::WritingMode; +use crate::properties::{ComputedValues, StyleBuilder}; +use crate::rule_tree::StrongRuleNode; +use crate::selector_parser::PseudoElement; +use crate::shared_lock::StylesheetGuards; +use crate::values::computed::NonNegativeLength; use fxhash::FxHashMap; -use logical_geometry::WritingMode; -use properties::{ComputedValues, StyleBuilder}; -use rule_tree::StrongRuleNode; -use selector_parser::PseudoElement; use servo_arc::Arc; -use shared_lock::StylesheetGuards; use smallvec::SmallVec; -use values::computed::NonNegativeLength; /// The conditions for caching and matching a style in the rule cache. #[derive(Clone, Debug, Default)] diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index c1b81889289..319d236d328 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -6,21 +6,21 @@ //! The rule tree. -use applicable_declarations::ApplicableDeclarationList; +use crate::applicable_declarations::ApplicableDeclarationList; +use crate::properties::{Importance, LonghandIdSet, PropertyDeclarationBlock}; +use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; +use crate::stylesheets::StyleRule; +use crate::thread_state; #[cfg(feature = "gecko")] use gecko::selector_parser::PseudoElement; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; -use properties::{Importance, LonghandIdSet, PropertyDeclarationBlock}; use servo_arc::{Arc, ArcBorrow, ArcUnion, ArcUnionBorrow}; -use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; use smallvec::SmallVec; use std::io::{self, Write}; use std::mem; use std::ptr; use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; -use stylesheets::StyleRule; -use thread_state; /// The rule tree, the structure servo uses to preserve the results of selector /// matching. @@ -1149,7 +1149,7 @@ impl StrongRuleNode { unsafe fn assert_free_list_has_no_duplicates_or_null(&self) { assert!(cfg!(debug_assertions), "This is an expensive check!"); - use hash::FxHashSet; + use crate::hash::FxHashSet; let me = &*self.ptr(); assert!(me.is_root()); @@ -1430,7 +1430,7 @@ impl StrongRuleNode { &self, guards: &StylesheetGuards, ) -> (LonghandIdSet, bool) { - use properties::PropertyDeclarationId; + use crate::properties::PropertyDeclarationId; // We want to iterate over cascade levels that override the animations // level, i.e. !important levels and the transitions level. diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index d9bf0771084..38503f69d05 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -5,22 +5,22 @@ //! A data structure to efficiently index structs containing selectors by local //! name, ids and hash. -use applicable_declarations::ApplicableDeclarationList; -use context::QuirksMode; -use dom::TElement; +use crate::applicable_declarations::ApplicableDeclarationList; +use crate::context::QuirksMode; +use crate::dom::TElement; +use crate::hash::map as hash_map; +use crate::hash::{HashMap, HashSet}; +use crate::rule_tree::{CascadeLevel, ShadowCascadeOrder}; +use crate::selector_parser::SelectorImpl; +use crate::stylist::Rule; +use crate::{Atom, LocalName, Namespace, WeakAtom}; use fallible::FallibleVec; -use hash::map as hash_map; -use hash::{HashMap, HashSet}; use hashglobe::FailedAllocationError; use precomputed_hash::PrecomputedHash; -use rule_tree::{CascadeLevel, ShadowCascadeOrder}; -use selector_parser::SelectorImpl; use selectors::matching::{matches_selector, ElementSelectorFlags, MatchingContext}; 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/components/style/selector_parser.rs b/components/style/selector_parser.rs index 1bfe115c5f4..ce85a693057 100644 --- a/components/style/selector_parser.rs +++ b/components/style/selector_parser.rs @@ -6,33 +6,33 @@ #![deny(missing_docs)] +use crate::element_state::ElementState; +use crate::stylesheets::{Namespaces, Origin, UrlExtraData}; +use crate::values::serialize_atom_identifier; +use crate::Atom; use cssparser::{Parser as CssParser, ParserInput}; -use element_state::ElementState; use selectors::parser::SelectorList; 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. pub type AttrValue = <SelectorImpl as ::selectors::SelectorImpl>::AttrValue; #[cfg(feature = "servo")] -pub use servo::selector_parser::*; +pub use crate::servo::selector_parser::*; #[cfg(feature = "gecko")] pub use gecko::selector_parser::*; #[cfg(feature = "servo")] -pub use servo::selector_parser::ServoElementSnapshot as Snapshot; +pub use crate::servo::selector_parser::ServoElementSnapshot as Snapshot; #[cfg(feature = "gecko")] pub use gecko::snapshot::GeckoElementSnapshot as Snapshot; #[cfg(feature = "servo")] -pub use servo::restyle_damage::ServoRestyleDamage as RestyleDamage; +pub use crate::servo::restyle_damage::ServoRestyleDamage as RestyleDamage; #[cfg(feature = "gecko")] pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage; diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index 77113e703c3..bb845f7ec41 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -5,20 +5,20 @@ //! Servo's media-query device and expression representation. use app_units::Au; +use crate::custom_properties::CssEnvironment; +use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements}; +use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription}; +use crate::media_queries::media_feature_expression::RangeOrOperator; +use crate::media_queries::MediaType; +use crate::properties::ComputedValues; +use crate::values::computed::font::FontSize; +use crate::values::computed::CSSPixelLength; +use crate::values::KeyframesName; use cssparser::RGBA; -use custom_properties::CssEnvironment; use euclid::{Size2D, TypedScale, TypedSize2D}; -use media_queries::media_feature::{AllowsRanges, ParsingRequirements}; -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::viewport::ViewportConstraints; 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/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs index 5f6eaa4c26f..73ac2f9fefd 100644 --- a/components/style/servo/restyle_damage.rs +++ b/components/style/servo/restyle_damage.rs @@ -5,9 +5,9 @@ //! The restyle damage is a hint that tells layout which kind of operations may //! be needed in presence of incremental style changes. -use computed_values::display::T as Display; -use matching::{StyleChange, StyleDifference}; -use properties::ComputedValues; +use crate::computed_values::display::T as Display; +use crate::matching::{StyleChange, StyleDifference}; +use crate::properties::ComputedValues; use std::fmt; bitflags! { diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index 97fb3e29854..a959a820edc 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -6,16 +6,19 @@ //! Servo's selector parser. -use attr::{AttrIdentifier, AttrValue}; +use crate::attr::{AttrIdentifier, AttrValue}; +use crate::dom::{OpaqueNode, TElement, TNode}; +use crate::element_state::{DocumentState, ElementState}; +use crate::invalidation::element::document_state::InvalidationMatchingData; +use crate::invalidation::element::element_wrapper::ElementSnapshot; +use crate::properties::longhands::display::computed_value::T as Display; +use crate::properties::{ComputedValues, PropertyFlags}; +use crate::selector_parser::{ + AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser, +}; +use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, Prefix}; use cssparser::{serialize_identifier, CowRcStr, Parser as CssParser, SourceLocation, ToCss}; -use dom::{OpaqueNode, TElement, TNode}; -use element_state::{DocumentState, ElementState}; use fxhash::FxHashMap; -use invalidation::element::document_state::InvalidationMatchingData; -use invalidation::element::element_wrapper::ElementSnapshot; -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}; use selectors::visitor::SelectorVisitor; @@ -23,7 +26,6 @@ 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. /// @@ -349,7 +351,7 @@ impl NonTSPseudoClass { /// selector matching, and it's set from the DOM. pub fn state_flag(&self) -> ElementState { use self::NonTSPseudoClass::*; - use element_state::ElementState; + use crate::element_state::ElementState; match *self { Active => ElementState::IN_ACTIVE_STATE, Focus => ElementState::IN_FOCUS_STATE, diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs index 56213e4978e..e3a4f76b50a 100644 --- a/components/style/servo/url.rs +++ b/components/style/servo/url.rs @@ -4,16 +4,16 @@ //! Common handling for the specified value CSS url() values. +use crate::parser::{Parse, ParserContext}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use servo_url::ServoUrl; use std::fmt::{self, Write}; // Note: We use std::sync::Arc rather than servo_arc::Arc here because the // nonzero optimization is important in keeping the size of SpecifiedUrl below // the threshold. +use crate::values::computed::{Context, ToComputedValue}; use std::sync::Arc; use style_traits::{CssWriter, ParseError, ToCss}; -use values::computed::{Context, ToComputedValue}; /// A CSS url() value for servo. /// diff --git a/components/style/shared_lock.rs b/components/style/shared_lock.rs index c36840254ad..2cf4e15daee 100644 --- a/components/style/shared_lock.rs +++ b/components/style/shared_lock.rs @@ -6,6 +6,8 @@ #[cfg(feature = "gecko")] use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; +use crate::str::{CssString, CssStringWriter}; +use crate::stylesheets::Origin; #[cfg(feature = "servo")] use parking_lot::RwLock; use servo_arc::Arc; @@ -15,8 +17,6 @@ use std::fmt; use std::mem; #[cfg(feature = "gecko")] use std::ptr; -use str::{CssString, CssStringWriter}; -use stylesheets::Origin; /// A shared read/write lock that can protect multiple objects. /// diff --git a/components/style/sharing/checks.rs b/components/style/sharing/checks.rs index 7e02b6d650c..960b9512e6e 100644 --- a/components/style/sharing/checks.rs +++ b/components/style/sharing/checks.rs @@ -6,11 +6,11 @@ //! quickly whether it's worth to share style, and whether two different //! elements can indeed share the same style. -use bloom::StyleBloom; -use context::{SelectorFlagsMap, SharedStyleContext}; -use dom::TElement; +use crate::bloom::StyleBloom; +use crate::context::{SelectorFlagsMap, SharedStyleContext}; +use crate::dom::TElement; +use crate::sharing::{StyleSharingCandidate, StyleSharingTarget}; use selectors::NthIndexCache; -use sharing::{StyleSharingCandidate, StyleSharingTarget}; /// Determines whether a target and a candidate have compatible parents for /// sharing. diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index f4ac8f30b13..9a62c8b54ad 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -64,15 +64,18 @@ //! selectors are effectively stripped off, so that matching them all against //! elements makes sense. -use applicable_declarations::ApplicableDeclarationBlock; use atomic_refcell::{AtomicRefCell, AtomicRefMut}; -use bloom::StyleBloom; -use context::{SelectorFlagsMap, SharedStyleContext, StyleContext}; -use dom::{SendElement, TElement}; -use matching::MatchMethods; +use crate::applicable_declarations::ApplicableDeclarationBlock; +use crate::bloom::StyleBloom; +use crate::context::{SelectorFlagsMap, SharedStyleContext, StyleContext}; +use crate::dom::{SendElement, TElement}; +use crate::matching::MatchMethods; +use crate::properties::ComputedValues; +use crate::rule_tree::StrongRuleNode; +use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles}; +use crate::stylist::Stylist; +use crate::Atom; use owning_ref::OwningHandle; -use properties::ComputedValues; -use rule_tree::StrongRuleNode; use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode}; use selectors::NthIndexCache; use servo_arc::Arc; @@ -82,10 +85,7 @@ use std::marker::PhantomData; use std::mem; use std::ops::Deref; use std::ptr::NonNull; -use style_resolver::{PrimaryStyle, ResolvedElementStyles}; -use stylist::Stylist; use uluru::{Entry, LRUCache}; -use Atom; mod checks; diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index 0b6005197b3..8e043f39f1f 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -6,13 +6,13 @@ //! a computed style needs in order for it to adhere to the CSS spec. use app_units::Au; -use dom::TElement; -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}; +use crate::dom::TElement; +use crate::properties::computed_value_flags::ComputedValueFlags; +use crate::properties::longhands::display::computed_value::T as Display; +use crate::properties::longhands::float::computed_value::T as Float; +use crate::properties::longhands::overflow_x::computed_value::T as Overflow; +use crate::properties::longhands::position::computed_value::T as Position; +use crate::properties::{self, ComputedValues, StyleBuilder}; /// A struct that implements all the adjustment methods. /// @@ -362,8 +362,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// See https://github.com/servo/servo/issues/15229 #[cfg(feature = "servo")] fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) { - use computed_values::align_items::T as AlignItems; - use computed_values::align_self::T as AlignSelf; + use crate::computed_values::align_items::T as AlignItems; + use crate::computed_values::align_self::T as AlignSelf; if self.style.get_position().clone_align_self() == AlignSelf::Auto && !self.style.out_of_flow_positioned() @@ -534,7 +534,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { /// and Blink have with this very same thing. #[cfg(feature = "servo")] fn adjust_for_text_decorations_in_effect(&mut self) { - use values::computed::text::TextDecorationsInEffect; + use crate::values::computed::text::TextDecorationsInEffect; let decorations_in_effect = TextDecorationsInEffect::from_style(&self.style); if self.style.get_inherited_text().text_decorations_in_effect != decorations_in_effect { diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index f1328858c3d..515f9ad39a9 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -4,21 +4,21 @@ //! Style resolution for a given element or pseudo-element. -use applicable_declarations::ApplicableDeclarationList; -use context::{CascadeInputs, ElementCascadeInputs, StyleContext}; -use data::{EagerPseudoStyles, ElementStyles}; -use dom::TElement; +use crate::applicable_declarations::ApplicableDeclarationList; +use crate::context::{CascadeInputs, ElementCascadeInputs, StyleContext}; +use crate::data::{EagerPseudoStyles, ElementStyles}; +use crate::dom::TElement; +use crate::matching::MatchMethods; +use crate::properties::longhands::display::computed_value::T as Display; +use crate::properties::{AnimationRules, ComputedValues}; +use crate::rule_tree::StrongRuleNode; +use crate::selector_parser::{PseudoElement, SelectorImpl}; +use crate::stylist::RuleInclusion; use log::Level::Trace; -use matching::MatchMethods; -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 servo_arc::Arc; -use stylist::RuleInclusion; /// Whether pseudo-elements should be resolved or not. #[derive(Clone, Copy, Debug, Eq, PartialEq)] @@ -111,7 +111,7 @@ fn eager_pseudo_is_definitely_not_generated( pseudo: &PseudoElement, style: &ComputedValues, ) -> bool { - use properties::computed_value_flags::ComputedValueFlags; + use crate::properties::computed_value_flags::ComputedValueFlags; if !pseudo.is_before_or_after() { return false; diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs index 19790aba957..0d7b6e73c10 100644 --- a/components/style/stylesheet_set.rs +++ b/components/style/stylesheet_set.rs @@ -4,13 +4,13 @@ //! A centralized set of stylesheets for a document. -use dom::TElement; -use invalidation::stylesheets::StylesheetInvalidationSet; -use media_queries::Device; -use selector_parser::SnapshotMap; -use shared_lock::SharedRwLockReadGuard; +use crate::dom::TElement; +use crate::invalidation::stylesheets::StylesheetInvalidationSet; +use crate::media_queries::Device; +use crate::selector_parser::SnapshotMap; +use crate::shared_lock::SharedRwLockReadGuard; +use crate::stylesheets::{Origin, OriginSet, OriginSetIterator, PerOrigin, StylesheetInDocument}; use std::{mem, slice}; -use stylesheets::{Origin, OriginSet, OriginSetIterator, PerOrigin, StylesheetInDocument}; /// Entry for a StylesheetSet. #[derive(MallocSizeOf)] diff --git a/components/style/stylesheets/counter_style_rule.rs b/components/style/stylesheets/counter_style_rule.rs index 64915b528c2..9cbc384cca7 100644 --- a/components/style/stylesheets/counter_style_rule.rs +++ b/components/style/stylesheets/counter_style_rule.rs @@ -4,4 +4,4 @@ #![allow(missing_docs)] -pub use counter_style::CounterStyleRuleData as CounterStyleRule; +pub use crate::counter_style::CounterStyleRuleData as CounterStyleRule; diff --git a/components/style/stylesheets/document_rule.rs b/components/style/stylesheets/document_rule.rs index 4dc36953ee2..d0642c86375 100644 --- a/components/style/stylesheets/document_rule.rs +++ b/components/style/stylesheets/document_rule.rs @@ -6,19 +6,19 @@ //! initially in CSS Conditional Rules Module Level 3, @document has been postponed to the level 4. //! We implement the prefixed `@-moz-document`. +use crate::media_queries::Device; +use crate::parser::{Parse, ParserContext}; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::CssRules; +use crate::values::CssUrl; use cssparser::{Parser, SourceLocation}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; -use media_queries::Device; -use parser::{Parse, ParserContext}; use servo_arc::Arc; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; -use str::CssStringWriter; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use stylesheets::CssRules; -use values::CssUrl; #[derive(Debug)] /// A @-moz-document rule @@ -135,7 +135,7 @@ impl DocumentMatchingFunction { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(url) = input.try(|input| CssUrl::parse(context, input)) { + if let Ok(url) = input.r#try(|input| CssUrl::parse(context, input)) { return Ok(DocumentMatchingFunction::Url(url)); } diff --git a/components/style/stylesheets/font_face_rule.rs b/components/style/stylesheets/font_face_rule.rs index 38568315069..7b19ceea69c 100644 --- a/components/style/stylesheets/font_face_rule.rs +++ b/components/style/stylesheets/font_face_rule.rs @@ -4,4 +4,4 @@ #![allow(missing_docs)] -pub use font_face::FontFaceRuleData as FontFaceRule; +pub use crate::font_face::FontFaceRuleData as FontFaceRule; diff --git a/components/style/stylesheets/font_feature_values_rule.rs b/components/style/stylesheets/font_feature_values_rule.rs index 548b060e014..b5c133034e2 100644 --- a/components/style/stylesheets/font_feature_values_rule.rs +++ b/components/style/stylesheets/font_feature_values_rule.rs @@ -6,23 +6,23 @@ //! //! [font-feature-values]: https://drafts.csswg.org/css-fonts-3/#at-font-feature-values-rule +use crate::error_reporting::ContextualParseError; +use crate::parser::{Parse, ParserContext}; +use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::CssRuleType; +use crate::values::computed::font::FamilyName; +use crate::values::serialize_atom_identifier; +use crate::Atom; use cssparser::{AtRuleParser, AtRuleType, BasicParseErrorKind, CowRcStr}; use cssparser::{DeclarationListParser, DeclarationParser, Parser}; use cssparser::{QualifiedRuleParser, RuleListParser, SourceLocation, Token}; -use error_reporting::ContextualParseError; #[cfg(feature = "gecko")] use gecko_bindings::bindings::Gecko_AppendFeatureValueHashEntry; #[cfg(feature = "gecko")] use gecko_bindings::structs::{self, gfxFontFeatureValueSet, nsTArray}; -use parser::{Parse, ParserContext}; -use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; -use str::CssStringWriter; 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 `<ident>: <integer>+`. diff --git a/components/style/stylesheets/import_rule.rs b/components/style/stylesheets/import_rule.rs index 576cb31eff3..b3e64455af9 100644 --- a/components/style/stylesheets/import_rule.rs +++ b/components/style/stylesheets/import_rule.rs @@ -6,16 +6,16 @@ //! //! [import]: https://drafts.csswg.org/css-cascade-3/#at-import -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::media_queries::MediaList; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::{CssRule, Origin, StylesheetInDocument}; +use crate::values::CssUrl; use cssparser::SourceLocation; -use media_queries::MediaList; -use shared_lock::{DeepCloneParams, DeepCloneWithLock}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; -use str::CssStringWriter; use style_traits::{CssWriter, ToCss}; -use stylesheets::{CssRule, Origin, StylesheetInDocument}; -use values::CssUrl; /// With asynchronous stylesheet parsing, we can't synchronously create a /// GeckoStyleSheet. So we use this placeholder instead. @@ -124,7 +124,7 @@ impl StylesheetInDocument for ImportSheet { /// A sheet that is held from an import rule. #[cfg(feature = "servo")] #[derive(Debug)] -pub struct ImportSheet(pub ::servo_arc::Arc<::stylesheets::Stylesheet>); +pub struct ImportSheet(pub ::servo_arc::Arc<crate::stylesheets::Stylesheet>); #[cfg(feature = "servo")] impl StylesheetInDocument for ImportSheet { diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs index ffd41551394..0824db67b5d 100644 --- a/components/style/stylesheets/keyframes_rule.rs +++ b/components/style/stylesheets/keyframes_rule.rs @@ -4,24 +4,24 @@ //! Keyframes: https://drafts.csswg.org/css-animations/#keyframes +use crate::error_reporting::ContextualParseError; +use crate::parser::ParserContext; +use crate::properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; +use crate::properties::LonghandIdSet; +use crate::properties::{Importance, PropertyDeclaration}; +use crate::properties::{LonghandId, PropertyDeclarationBlock, PropertyId}; +use crate::properties::{PropertyDeclarationId, SourcePropertyDeclaration}; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard}; +use crate::shared_lock::{Locked, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::rule_parser::VendorPrefix; +use crate::stylesheets::{CssRuleType, StylesheetContents}; +use crate::values::{serialize_percentage, KeyframesName}; use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, 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 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::rule_parser::VendorPrefix; -use stylesheets::{CssRuleType, StylesheetContents}; -use values::{serialize_percentage, KeyframesName}; /// A [`@keyframes`][keyframes] rule. /// diff --git a/components/style/stylesheets/loader.rs b/components/style/stylesheets/loader.rs index baab9df3838..0ae7f1bcb62 100644 --- a/components/style/stylesheets/loader.rs +++ b/components/style/stylesheets/loader.rs @@ -5,13 +5,13 @@ //! The stylesheet loader is the abstraction used to trigger network requests //! for `@import` rules. +use crate::media_queries::MediaList; +use crate::parser::ParserContext; +use crate::shared_lock::{Locked, SharedRwLock}; +use crate::stylesheets::import_rule::ImportRule; +use crate::values::CssUrl; use cssparser::SourceLocation; -use media_queries::MediaList; -use parser::ParserContext; use servo_arc::Arc; -use shared_lock::{Locked, SharedRwLock}; -use stylesheets::import_rule::ImportRule; -use values::CssUrl; /// The stylesheet loader is the abstraction used to trigger network requests /// for `@import` rules. diff --git a/components/style/stylesheets/media_rule.rs b/components/style/stylesheets/media_rule.rs index 4ae54c18f2b..c131476c65c 100644 --- a/components/style/stylesheets/media_rule.rs +++ b/components/style/stylesheets/media_rule.rs @@ -6,17 +6,17 @@ //! //! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media +use crate::media_queries::MediaList; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::CssRules; use cssparser::SourceLocation; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; -use media_queries::MediaList; use servo_arc::Arc; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; -use str::CssStringWriter; use style_traits::{CssWriter, ToCss}; -use stylesheets::CssRules; /// An [`@media`][media] urle. /// diff --git a/components/style/stylesheets/mod.rs b/components/style/stylesheets/mod.rs index 9e1ae186d55..1c1c0f6128f 100644 --- a/components/style/stylesheets/mod.rs +++ b/components/style/stylesheets/mod.rs @@ -23,15 +23,15 @@ mod stylesheet; pub mod supports_rule; pub mod viewport_rule; +use crate::parser::ParserContext; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; use cssparser::{parse_one_rule, Parser, ParserInput}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; -use parser::ParserContext; use servo_arc::Arc; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt; -use str::CssStringWriter; use style_traits::ParsingMode; pub use self::counter_style_rule::CounterStyleRule; diff --git a/components/style/stylesheets/namespace_rule.rs b/components/style/stylesheets/namespace_rule.rs index 1f927f08f17..3240557474b 100644 --- a/components/style/stylesheets/namespace_rule.rs +++ b/components/style/stylesheets/namespace_rule.rs @@ -4,11 +4,11 @@ //! The `@namespace` at-rule. +use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::{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/components/style/stylesheets/page_rule.rs b/components/style/stylesheets/page_rule.rs index 732231ca0ce..9ad53714faf 100644 --- a/components/style/stylesheets/page_rule.rs +++ b/components/style/stylesheets/page_rule.rs @@ -6,15 +6,15 @@ //! //! [page]: https://drafts.csswg.org/css2/page.html#page-box +use crate::properties::PropertyDeclarationBlock; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; use cssparser::SourceLocation; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; -use properties::PropertyDeclarationBlock; use servo_arc::Arc; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; -use str::CssStringWriter; /// A [`@page`][page] rule. /// diff --git a/components/style/stylesheets/rule_list.rs b/components/style/stylesheets/rule_list.rs index 280f879a77b..df86a02e51e 100644 --- a/components/style/stylesheets/rule_list.rs +++ b/components/style/stylesheets/rule_list.rs @@ -4,17 +4,17 @@ //! A list of CSS rules. +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::loader::StylesheetLoader; +use crate::stylesheets::rule_parser::{InsertRuleContext, State}; +use crate::stylesheets::stylesheet::StylesheetContents; +use crate::stylesheets::{CssRule, RulesMutateError}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps}; use servo_arc::{Arc, RawOffsetArc}; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; -use str::CssStringWriter; -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/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 642eabd9b6a..afb6debc1e1 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -4,32 +4,32 @@ //! Parsing of the stylesheet contents. -use counter_style::{parse_counter_style_body, parse_counter_style_name_definition}; +use crate::counter_style::{parse_counter_style_body, parse_counter_style_name_definition}; +use crate::error_reporting::ContextualParseError; +use crate::font_face::parse_font_face_block; +use crate::media_queries::MediaList; +use crate::parser::{Parse, ParserContext}; +use crate::properties::parse_property_declaration_list; +use crate::selector_parser::{SelectorImpl, SelectorParser}; +use crate::shared_lock::{Locked, SharedRwLock}; +use crate::str::starts_with_ignore_ascii_case; +use crate::stylesheets::document_rule::DocumentCondition; +use crate::stylesheets::font_feature_values_rule::parse_family_name_list; +use crate::stylesheets::keyframes_rule::parse_keyframe_list; +use crate::stylesheets::stylesheet::Namespaces; +use crate::stylesheets::supports_rule::SupportsCondition; +use crate::stylesheets::viewport_rule; +use crate::stylesheets::{CssRule, CssRuleType, CssRules, RulesMutateError, StylesheetLoader}; +use crate::stylesheets::{DocumentRule, FontFeatureValuesRule, KeyframesRule, MediaRule}; +use crate::stylesheets::{NamespaceRule, PageRule, StyleRule, SupportsRule, ViewportRule}; +use crate::values::computed::font::FamilyName; +use crate::values::{CssUrl, CustomIdent, KeyframesName}; +use crate::{Namespace, Prefix}; use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser}; use cssparser::{BasicParseError, BasicParseErrorKind, CowRcStr, SourceLocation}; -use error_reporting::ContextualParseError; -use font_face::parse_font_face_block; -use media_queries::MediaList; -use parser::{Parse, ParserContext}; -use properties::parse_property_declaration_list; -use selector_parser::{SelectorImpl, SelectorParser}; use selectors::SelectorList; use servo_arc::Arc; -use shared_lock::{Locked, SharedRwLock}; -use str::starts_with_ignore_ascii_case; use style_traits::{ParseError, StyleParseErrorKind}; -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 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> { @@ -202,7 +202,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> { return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedNamespaceRule)) } - let prefix = input.try(|i| i.expect_ident_cloned()) + let prefix = input.r#try(|i| i.expect_ident_cloned()) .map(|s| Prefix::from(s.as_ref())).ok(); let maybe_namespace = match input.expect_url_or_string() { Ok(url_or_string) => url_or_string, diff --git a/components/style/stylesheets/rules_iterator.rs b/components/style/stylesheets/rules_iterator.rs index 5609e75f215..4f5c8c95d8a 100644 --- a/components/style/stylesheets/rules_iterator.rs +++ b/components/style/stylesheets/rules_iterator.rs @@ -4,13 +4,13 @@ //! An iterator over a list of rules. -use context::QuirksMode; -use media_queries::Device; -use shared_lock::SharedRwLockReadGuard; +use crate::context::QuirksMode; +use crate::media_queries::Device; +use crate::shared_lock::SharedRwLockReadGuard; +use crate::stylesheets::StylesheetInDocument; +use crate::stylesheets::{CssRule, DocumentRule, ImportRule, MediaRule, SupportsRule}; use smallvec::SmallVec; use std::slice; -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/components/style/stylesheets/style_rule.rs b/components/style/stylesheets/style_rule.rs index a017b38bdf5..1e5cc0bfc4f 100644 --- a/components/style/stylesheets/style_rule.rs +++ b/components/style/stylesheets/style_rule.rs @@ -4,19 +4,19 @@ //! A style rule. +use crate::properties::PropertyDeclarationBlock; +use crate::selector_parser::SelectorImpl; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; use cssparser::SourceLocation; #[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; use servo_arc::Arc; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt::{self, Write}; -use str::CssStringWriter; /// A style rule, with selectors and declarations. #[derive(Debug)] diff --git a/components/style/stylesheets/stylesheet.rs b/components/style/stylesheets/stylesheet.rs index 9bdc9c6834b..2749225f2aa 100644 --- a/components/style/stylesheets/stylesheet.rs +++ b/components/style/stylesheets/stylesheet.rs @@ -2,31 +2,31 @@ * 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 context::QuirksMode; +use crate::context::QuirksMode; +use crate::error_reporting::{ContextualParseError, ParseErrorReporter}; +use crate::invalidation::media_queries::{MediaListKey, ToMediaListKey}; +use crate::media_queries::{Device, MediaList}; +use crate::parser::ParserContext; +use crate::shared_lock::{ + DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, +}; +use crate::stylesheets::loader::StylesheetLoader; +use crate::stylesheets::rule_parser::{State, TopLevelRuleParser}; +use crate::stylesheets::rules_iterator::{EffectiveRules, EffectiveRulesIterator}; +use crate::stylesheets::rules_iterator::{NestedRuleIterationCondition, RulesIterator}; +use crate::stylesheets::{CssRule, CssRules, Origin, UrlExtraData}; +use crate::use_counters::UseCounters; +use crate::{Namespace, Prefix}; use cssparser::{Parser, ParserInput, RuleListParser}; -use error_reporting::{ContextualParseError, ParseErrorReporter}; use fallible::FallibleVec; use fxhash::FxHashMap; -use invalidation::media_queries::{MediaListKey, ToMediaListKey}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; -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 std::mem; use std::sync::atomic::{AtomicBool, Ordering}; use style_traits::ParsingMode; -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 { @@ -166,9 +166,9 @@ macro_rules! rule_filter { $( #[allow(missing_docs)] fn $method<F>(&self, device: &Device, guard: &SharedRwLockReadGuard, mut f: F) - where F: FnMut(&::stylesheets::$rule_type), + where F: FnMut(&crate::stylesheets::$rule_type), { - use stylesheets::CssRule; + use crate::stylesheets::CssRule; for rule in self.effective_rules(device, guard) { if let CssRule::$variant(ref lock) = *rule { diff --git a/components/style/stylesheets/supports_rule.rs b/components/style/stylesheets/supports_rule.rs index a273dcb48a9..67eb6984477 100644 --- a/components/style/stylesheets/supports_rule.rs +++ b/components/style/stylesheets/supports_rule.rs @@ -4,24 +4,24 @@ //! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports) +use crate::parser::ParserContext; +use crate::properties::{PropertyDeclaration, PropertyId, SourcePropertyDeclaration}; +use crate::selector_parser::{SelectorImpl, SelectorParser}; +use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; +use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::{CssRuleType, CssRules, Namespaces}; use cssparser::parse_important; use cssparser::{Delimiter, Parser, SourceLocation, Token}; use cssparser::{ParseError as CssParseError, ParserInput}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; -use parser::ParserContext; -use properties::{PropertyDeclaration, PropertyId, SourcePropertyDeclaration}; -use selector_parser::{SelectorImpl, SelectorParser}; use selectors::parser::{Selector, SelectorParseErrorKind}; use servo_arc::Arc; -use shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked}; -use shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard}; use std::ffi::{CStr, CString}; use std::fmt::{self, Write}; use std::str; -use str::CssStringWriter; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use stylesheets::{CssRuleType, CssRules, Namespaces}; /// An [`@supports`][supports] rule. /// @@ -103,7 +103,7 @@ impl SupportsCondition { /// /// <https://drafts.csswg.org/css-conditional/#supports_condition> pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("not")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("not")).is_ok() { let inner = SupportsCondition::parse_in_parens(input)?; return Ok(SupportsCondition::Not(Box::new(inner))); } @@ -129,7 +129,7 @@ impl SupportsCondition { loop { conditions.push(SupportsCondition::parse_in_parens(input)?); if input - .try(|input| input.expect_ident_matching(keyword)) + .r#try(|input| input.expect_ident_matching(keyword)) .is_err() { // Did not find the expected keyword. @@ -175,20 +175,20 @@ impl SupportsCondition { fn parse_in_parens<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { // 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() {} + while input.r#try(Parser::expect_whitespace).is_ok() {} let pos = input.position(); let location = input.current_source_location(); // 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)); + input.r#try(|input| input.parse_nested_block(parse_condition_or_declaration)); if nested.is_ok() { return nested; } }, Token::Function(ident) => { - let nested = input.try(|input| { + let nested = input.r#try(|input| { input.parse_nested_block(|input| { SupportsCondition::parse_functional(&ident, input) }) @@ -240,7 +240,7 @@ fn eval_moz_bool_pref(_: &CStr, _: &ParserContext) -> bool { pub fn parse_condition_or_declaration<'i, 't>( input: &mut Parser<'i, 't>, ) -> Result<SupportsCondition, ParseError<'i>> { - if let Ok(condition) = input.try(SupportsCondition::parse) { + if let Ok(condition) = input.r#try(SupportsCondition::parse) { Ok(SupportsCondition::Parenthesized(Box::new(condition))) } else { Declaration::parse(input).map(SupportsCondition::Declaration) @@ -418,7 +418,7 @@ impl Declaration { PropertyDeclaration::parse_into(&mut declarations, id, &context, input) .map_err(|_| input.new_custom_error(())) })?; - let _ = input.try(parse_important); + let _ = input.r#try(parse_important); Ok(()) }) .is_ok() diff --git a/components/style/stylesheets/viewport_rule.rs b/components/style/stylesheets/viewport_rule.rs index 741e577229d..de2fd55fb7b 100644 --- a/components/style/stylesheets/viewport_rule.rs +++ b/components/style/stylesheets/viewport_rule.rs @@ -8,29 +8,29 @@ //! [meta]: https://drafts.csswg.org/css-device-adapt/#viewport-meta use app_units::Au; -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::error_reporting::ContextualParseError; +use crate::font_metrics::get_metrics_provider_for_product; +use crate::media_queries::Device; +use crate::parser::ParserContext; +use crate::properties::StyleBuilder; +use crate::rule_cache::RuleCacheConditions; +use crate::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard}; +use crate::str::CssStringWriter; +use crate::stylesheets::{Origin, StylesheetInDocument}; +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::specified::{LengthOrPercentageOrAuto, NoCalcLength, ViewportPercentageLength}; 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; -use media_queries::Device; -use parser::ParserContext; -use properties::StyleBuilder; -use rule_cache::RuleCacheConditions; use selectors::parser::SelectorParseErrorKind; -use shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard}; use std::borrow::Cow; use std::cell::RefCell; use std::fmt::{self, Write}; use std::iter::Enumerate; use std::str::Chars; -use str::CssStringWriter; 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}; /// Whether parsing and processing of `@viewport` rules is enabled. #[cfg(feature = "servo")] @@ -265,7 +265,7 @@ fn parse_shorthand<'i, 't>( input: &mut Parser<'i, 't>, ) -> Result<(ViewportLength, ViewportLength), ParseError<'i>> { let min = ViewportLength::parse(context, input)?; - match input.try(|i| ViewportLength::parse(context, i)) { + match input.r#try(|i| ViewportLength::parse(context, i)) { Err(_) => Ok((min.clone(), min)), Ok(max) => Ok((min, max)), } @@ -289,8 +289,8 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for ViewportRuleParser<'a, 'b> { ) -> Result<Vec<ViewportDescriptorDeclaration>, ParseError<'i>> { macro_rules! declaration { ($declaration:ident($parse:expr)) => { - declaration!($declaration(value: try!($parse(input)), - important: input.try(parse_important).is_ok())) + declaration!($declaration(value: r#try!($parse(input)), + important: input.r#try(parse_important).is_ok())) }; ($declaration:ident(value: $value:expr, important: $important:expr)) => { ViewportDescriptorDeclaration::new( @@ -306,7 +306,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for ViewportRuleParser<'a, 'b> { }; (shorthand -> [$min:ident, $max:ident]) => {{ let shorthand = parse_shorthand(self.context, input)?; - let important = input.try(parse_important).is_ok(); + let important = input.r#try(parse_important).is_ok(); Ok(vec![ declaration!($min(value: shorthand.0, important: important)), diff --git a/components/style/stylist.rs b/components/style/stylist.rs index cd6ed7257e5..9ed9e056fd7 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -4,27 +4,37 @@ //! Selector matching. -use applicable_declarations::{ApplicableDeclarationBlock, ApplicableDeclarationList}; -use context::{CascadeInputs, QuirksMode}; -use dom::{TElement, TShadowRoot}; -use element_state::{DocumentState, ElementState}; -use font_metrics::FontMetricsProvider; +use crate::applicable_declarations::{ApplicableDeclarationBlock, ApplicableDeclarationList}; +use crate::context::{CascadeInputs, QuirksMode}; +use crate::dom::{TElement, TShadowRoot}; +use crate::element_state::{DocumentState, ElementState}; +use crate::font_metrics::FontMetricsProvider; +use crate::invalidation::element::invalidation_map::InvalidationMap; +use crate::invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey}; +use crate::media_queries::Device; +use crate::properties::{self, CascadeMode, ComputedValues}; +use crate::properties::{AnimationRules, PropertyDeclarationBlock}; +use crate::rule_cache::{RuleCache, RuleCacheConditions}; +use crate::rule_tree::{CascadeLevel, RuleTree, ShadowCascadeOrder, StrongRuleNode, StyleSource}; +use crate::selector_map::{PrecomputedHashMap, PrecomputedHashSet, SelectorMap, SelectorMapEntry}; +use crate::selector_parser::{PerPseudoElementMap, PseudoElement, SelectorImpl, SnapshotMap}; +use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; +use crate::stylesheet_set::{DataValidity, DocumentStylesheetSet, SheetRebuildKind}; +use crate::stylesheet_set::{DocumentStylesheetFlusher, SheetCollectionFlusher}; +use crate::stylesheets::keyframes_rule::KeyframesAnimation; +use crate::stylesheets::viewport_rule::{self, MaybeNew, ViewportRule}; +use crate::stylesheets::StyleRule; +use crate::stylesheets::StylesheetInDocument; +use crate::stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter}; +use crate::thread_state::{self, ThreadState}; +use crate::{Atom, LocalName, Namespace, WeakAtom}; #[cfg(feature = "gecko")] use gecko_bindings::structs::{ServoStyleSetSizes, StyleRuleInclusion}; use hashglobe::FailedAllocationError; -use invalidation::element::invalidation_map::InvalidationMap; -use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey}; #[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}; -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::attr::{CaseSensitivity, NamespaceConstraint}; use selectors::bloom::BloomFilter; use selectors::matching::VisitedHandlingMode; @@ -34,27 +44,17 @@ 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; use smallvec::SmallVec; use std::ops; 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 thread_state::{self, ThreadState}; -use {Atom, LocalName, Namespace, WeakAtom}; /// The type of the stylesheets that the stylist contains. #[cfg(feature = "servo")] -pub type StylistSheet = ::stylesheets::DocumentStyleSheet; +pub type StylistSheet = crate::stylesheets::DocumentStyleSheet; /// The type of the stylesheets that the stylist contains. #[cfg(feature = "gecko")] @@ -719,7 +719,7 @@ impl Stylist { where E: TElement, { - use font_metrics::ServoMetricsProvider; + use crate::font_metrics::ServoMetricsProvider; self.precomputed_values_for_pseudo::<E>( guards, &pseudo, @@ -1556,7 +1556,7 @@ impl Stylist { where E: TElement, { - use font_metrics::get_metrics_provider_for_product; + use crate::font_metrics::get_metrics_provider_for_product; let block = declarations.read_with(guards.author); let iter_declarations = || { @@ -2333,7 +2333,7 @@ impl CascadeData { where S: StylesheetInDocument + ToMediaListKey + 'static, { - use invalidation::media_queries::PotentiallyEffectiveMediaRules; + use crate::invalidation::media_queries::PotentiallyEffectiveMediaRules; let effective_now = stylesheet.is_effective_for_device(device, guard); diff --git a/components/style/traversal.rs b/components/style/traversal.rs index d207c196d66..720f1f7831c 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -4,18 +4,18 @@ //! Traversing the DOM tree; the bloom filter. -use context::{ElementCascadeInputs, SharedStyleContext, StyleContext}; -use data::{ElementData, ElementStyles}; -use dom::{NodeInfo, OpaqueNode, TElement, TNode}; -use invalidation::element::restyle_hints::RestyleHint; -use matching::{ChildCascadeRequirement, MatchMethods}; -use selector_parser::PseudoElement; +use crate::context::{ElementCascadeInputs, SharedStyleContext, StyleContext}; +use crate::data::{ElementData, ElementStyles}; +use crate::dom::{NodeInfo, OpaqueNode, TElement, TNode}; +use crate::invalidation::element::restyle_hints::RestyleHint; +use crate::matching::{ChildCascadeRequirement, MatchMethods}; +use crate::selector_parser::PseudoElement; +use crate::sharing::StyleSharingTarget; +use crate::style_resolver::{PseudoElementResolution, StyleResolverForElement}; +use crate::stylist::RuleInclusion; +use crate::traversal_flags::TraversalFlags; use selectors::NthIndexCache; -use sharing::StyleSharingTarget; use smallvec::SmallVec; -use style_resolver::{PseudoElementResolution, StyleResolverForElement}; -use stylist::RuleInclusion; -use traversal_flags::TraversalFlags; /// A per-traversal-level chunk of data. This is sent down by the traversal, and /// currently only holds the dom depth for the bloom filter. @@ -307,7 +307,7 @@ pub fn resolve_style<E>( where E: TElement, { - use style_resolver::StyleResolverForElement; + use crate::style_resolver::StyleResolverForElement; debug_assert!( rule_inclusion == RuleInclusion::DefaultOnly || @@ -406,8 +406,8 @@ pub fn recalc_style_at<E, D, F>( D: DomTraversal<E>, F: FnMut(E::ConcreteNode), { + use crate::traversal_flags::TraversalFlags; use std::cmp; - use traversal_flags::TraversalFlags; let flags = context.shared.traversal_flags; let is_initial_style = !data.has_styles(); @@ -586,7 +586,7 @@ fn compute_style<E>( where E: TElement, { - use data::RestyleKind::*; + use crate::data::RestyleKind::*; context.thread_local.statistics.elements_styled += 1; let kind = data.restyle_kind(context.shared); @@ -719,9 +719,9 @@ fn notify_paint_worklet<E>(context: &StyleContext<E>, data: &ElementData) where E: TElement, { + use crate::values::generics::image::Image; + use crate::values::Either; use style_traits::ToCss; - 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. @@ -811,7 +811,7 @@ fn note_children<E, D, F>( child_hint |= RestyleHint::RECASCADE_SELF | RestyleHint::RECASCADE_DESCENDANTS; }, ChildCascadeRequirement::MustCascadeChildrenIfInheritResetStyle => { - use properties::computed_value_flags::ComputedValueFlags; + use crate::properties::computed_value_flags::ComputedValueFlags; if child_data .styles .primary() diff --git a/components/style/use_counters/mod.rs b/components/style/use_counters/mod.rs index 49c77ae714d..6c091f32952 100644 --- a/components/style/use_counters/mod.rs +++ b/components/style/use_counters/mod.rs @@ -4,9 +4,9 @@ //! Various stuff for CSS property use counters. +use crate::properties::{NonCustomPropertyId, NON_CUSTOM_PROPERTY_ID_COUNT}; #[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; -use properties::{NonCustomPropertyId, NON_CUSTOM_PROPERTY_ID_COUNT}; use std::cell::Cell; #[cfg(target_pointer_width = "64")] diff --git a/components/style/values/animated/color.rs b/components/style/values/animated/color.rs index afffce1c767..84f03ce8eb4 100644 --- a/components/style/values/animated/color.rs +++ b/components/style/values/animated/color.rs @@ -4,9 +4,9 @@ //! Animated types for CSS colors. -use values::animated::{Animate, Procedure, ToAnimatedZero}; -use values::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::generics::color::{Color as GenericColor, ComplexColorRatios}; +use crate::values::animated::{Animate, Procedure, ToAnimatedZero}; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use crate::values::generics::color::{Color as GenericColor, ComplexColorRatios}; /// An animated RGBA color. /// diff --git a/components/style/values/animated/effects.rs b/components/style/values/animated/effects.rs index 674a601764a..0dc710dce24 100644 --- a/components/style/values/animated/effects.rs +++ b/components/style/values/animated/effects.rs @@ -4,16 +4,16 @@ //! Animated types for CSS values related to effects. -use values::animated::color::Color; -use values::computed::length::Length; +use crate::values::animated::color::Color; +use crate::values::computed::length::Length; +use crate::values::computed::{Angle, Number}; +use crate::values::generics::effects::BoxShadow as GenericBoxShadow; +use crate::values::generics::effects::Filter as GenericFilter; +use crate::values::generics::effects::SimpleShadow as GenericSimpleShadow; +#[cfg(not(feature = "gecko"))] +use crate::values::Impossible; #[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<Color, Length, Length, Length>; diff --git a/components/style/values/animated/font.rs b/components/style/values/animated/font.rs index 65050ffe1da..f732776cf1a 100644 --- a/components/style/values/animated/font.rs +++ b/components/style/values/animated/font.rs @@ -5,10 +5,10 @@ //! Animation implementation for various font-related types. use super::{Animate, Procedure, ToAnimatedZero}; -use values::computed::font::{FontVariationSettings, FontWeight}; -use values::computed::Number; -use values::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::generics::font::{FontSettings as GenericFontSettings, FontTag, VariationValue}; +use crate::values::computed::font::{FontVariationSettings, FontWeight}; +use crate::values::computed::Number; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use crate::values::generics::font::{FontSettings as GenericFontSettings, FontTag, VariationValue}; impl ToAnimatedZero for FontWeight { #[inline] diff --git a/components/style/values/animated/length.rs b/components/style/values/animated/length.rs index 823b9ed84e9..25cb7855f13 100644 --- a/components/style/values/animated/length.rs +++ b/components/style/values/animated/length.rs @@ -5,11 +5,11 @@ //! Animation implementation for various length-related types. use super::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; -use values::computed::length::{CalcLengthOrPercentage, Length}; -use values::computed::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; -use values::computed::MaxLength as ComputedMaxLength; -use values::computed::MozLength as ComputedMozLength; -use values::computed::Percentage; +use crate::values::computed::length::{CalcLengthOrPercentage, Length}; +use crate::values::computed::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; +use crate::values::computed::MaxLength as ComputedMaxLength; +use crate::values::computed::MozLength as ComputedMozLength; +use crate::values::computed::Percentage; /// <https://drafts.csswg.org/css-transitions/#animtype-lpcalc> impl Animate for CalcLengthOrPercentage { @@ -74,8 +74,8 @@ impl ToAnimatedValue for ComputedMaxLength { #[inline] fn from_animated_value(animated: Self::AnimatedValue) -> Self { - use values::computed::{Length, LengthOrPercentageOrNone, Percentage}; - use values::generics::length::MaxLength as GenericMaxLength; + use crate::values::computed::{Length, LengthOrPercentageOrNone, Percentage}; + use crate::values::generics::length::MaxLength as GenericMaxLength; match animated { GenericMaxLength::LengthOrPercentageOrNone(lopn) => { let result = match lopn { @@ -104,8 +104,8 @@ impl ToAnimatedValue for ComputedMozLength { #[inline] fn from_animated_value(animated: Self::AnimatedValue) -> Self { - use values::computed::{Length, LengthOrPercentageOrAuto, Percentage}; - use values::generics::length::MozLength as GenericMozLength; + use crate::values::computed::{Length, LengthOrPercentageOrAuto, Percentage}; + use crate::values::generics::length::MozLength as GenericMozLength; match animated { GenericMozLength::LengthOrPercentageOrAuto(lopa) => { let result = match lopa { diff --git a/components/style/values/animated/mod.rs b/components/style/values/animated/mod.rs index 707fc263c70..446e3618e08 100644 --- a/components/style/values/animated/mod.rs +++ b/components/style/values/animated/mod.rs @@ -9,14 +9,14 @@ //! module's raison d'être is to ultimately contain all these types. use app_units::Au; +use crate::properties::PropertyId; +use crate::values::computed::length::CalcLengthOrPercentage; +use crate::values::computed::url::ComputedUrl; +use crate::values::computed::Angle as ComputedAngle; +use crate::values::computed::BorderCornerRadius as ComputedBorderCornerRadius; use euclid::{Point2D, Size2D}; -use properties::PropertyId; use smallvec::SmallVec; use std::cmp; -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; diff --git a/components/style/values/animated/svg.rs b/components/style/values/animated/svg.rs index 630a2203252..b01f35e7cb3 100644 --- a/components/style/values/animated/svg.rs +++ b/components/style/values/animated/svg.rs @@ -5,13 +5,13 @@ //! Animation implementations for various SVG-related types. use super::{Animate, Procedure, ToAnimatedZero}; -use properties::animated_properties::ListAnimation; -use values::animated::color::Color as AnimatedColor; -use values::computed::url::ComputedUrl; -use values::computed::{LengthOrPercentage, Number, NumberOrPercentage}; -use values::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::generics::svg::{SVGLength, SVGPaint, SvgLengthOrPercentageOrNumber}; -use values::generics::svg::{SVGOpacity, SVGStrokeDashArray}; +use crate::properties::animated_properties::ListAnimation; +use crate::values::animated::color::Color as AnimatedColor; +use crate::values::computed::url::ComputedUrl; +use crate::values::computed::{LengthOrPercentage, Number, NumberOrPercentage}; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use crate::values::generics::svg::{SVGLength, SVGPaint, SvgLengthOrPercentageOrNumber}; +use crate::values::generics::svg::{SVGOpacity, SVGStrokeDashArray}; /// Animated SVGPaint. pub type IntermediateSVGPaint = SVGPaint<AnimatedColor, ComputedUrl>; diff --git a/components/style/values/computed/angle.rs b/components/style/values/computed/angle.rs index 3f697578cd5..149a33813c6 100644 --- a/components/style/values/computed/angle.rs +++ b/components/style/values/computed/angle.rs @@ -4,14 +4,14 @@ //! Computed angles. +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use crate::values::CSSFloat; use num_traits::Zero; 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::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::CSSFloat; /// A computed angle in degrees. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] diff --git a/components/style/values/computed/background.rs b/components/style/values/computed/background.rs index 78b9a92a9d0..fd1348a9e97 100644 --- a/components/style/values/computed/background.rs +++ b/components/style/values/computed/background.rs @@ -4,13 +4,13 @@ //! Computed types for CSS values related to backgrounds. +use crate::values::computed::length::NonNegativeLengthOrPercentageOrAuto; +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::generics::background::BackgroundSize as GenericBackgroundSize; +use crate::values::specified::background::BackgroundRepeat as SpecifiedBackgroundRepeat; +use crate::values::specified::background::BackgroundRepeatKeyword; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -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; /// A computed value for the `background-size` property. pub type BackgroundSize = GenericBackgroundSize<NonNegativeLengthOrPercentageOrAuto>; diff --git a/components/style/values/computed/basic_shape.rs b/components/style/values/computed/basic_shape.rs index 9c6cdb66260..72db73fb676 100644 --- a/components/style/values/computed/basic_shape.rs +++ b/components/style/values/computed/basic_shape.rs @@ -7,14 +7,14 @@ //! //! [basic-shape]: https://drafts.csswg.org/css-shapes/#typedef-basic-shape +use crate::values::computed::url::ComputedUrl; +use crate::values::computed::{Image, LengthOrPercentage}; +use crate::values::generics::basic_shape as generic; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::computed::url::ComputedUrl; -use values::computed::{Image, LengthOrPercentage}; -use values::generics::basic_shape as generic; /// A computed alias for FillRule. -pub use values::generics::basic_shape::FillRule; +pub use crate::values::generics::basic_shape::FillRule; /// A computed clipping shape. pub type ClippingShape = generic::ClippingShape<BasicShape, ComputedUrl>; diff --git a/components/style/values/computed/border.rs b/components/style/values/computed/border.rs index 9a92175d978..4b736380f66 100644 --- a/components/style/values/computed/border.rs +++ b/components/style/values/computed/border.rs @@ -5,18 +5,18 @@ //! Computed types for CSS values related to borders. use app_units::Au; -use values::animated::ToAnimatedZero; -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; -use values::generics::border::BorderRadius as GenericBorderRadius; -use values::generics::border::BorderSpacing as GenericBorderSpacing; -use values::generics::rect::Rect; -use values::generics::size::Size; - -pub use values::specified::border::BorderImageRepeat; +use crate::values::animated::ToAnimatedZero; +use crate::values::computed::length::{LengthOrPercentage, NonNegativeLength}; +use crate::values::computed::{Number, NumberOrPercentage}; +use crate::values::generics::border::BorderCornerRadius as GenericBorderCornerRadius; +use crate::values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth; +use crate::values::generics::border::BorderImageSlice as GenericBorderImageSlice; +use crate::values::generics::border::BorderRadius as GenericBorderRadius; +use crate::values::generics::border::BorderSpacing as GenericBorderSpacing; +use crate::values::generics::rect::Rect; +use crate::values::generics::size::Size; + +pub use crate::values::specified::border::BorderImageRepeat; /// A computed value for the `border-image-width` property. pub type BorderImageWidth = Rect<BorderImageSideWidth>; diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index 3e219305eff..0cf6ab3e39c 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -4,16 +4,18 @@ //! Computed types for box properties. -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; -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_::{ +use crate::values::computed::length::{LengthOrPercentage, NonNegativeLength}; +use crate::values::computed::{Context, Number, ToComputedValue}; +use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; +use crate::values::generics::box_::Perspective as GenericPerspective; +use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign; +use crate::values::specified::box_ as specified; + +pub use crate::values::specified::box_::{ + AnimationName, Appearance, Contain, Display, OverflowClipBox, +}; +pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; +pub use crate::values::specified::box_::{ OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange, }; diff --git a/components/style/values/computed/color.rs b/components/style/values/computed/color.rs index 6d0713ac1d4..ba0495cc613 100644 --- a/components/style/values/computed/color.rs +++ b/components/style/values/computed/color.rs @@ -4,12 +4,12 @@ //! Computed color values. +use crate::values::animated::color::RGBA as AnimatedRGBA; +use crate::values::animated::ToAnimatedValue; +use crate::values::generics::color::Color as GenericColor; use cssparser::{Color as CSSParserColor, RGBA}; use std::fmt; use style_traits::{CssWriter, ToCss}; -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. pub type RGBAColor = RGBA; diff --git a/components/style/values/computed/column.rs b/components/style/values/computed/column.rs index 6e283fb1bac..8e715635d57 100644 --- a/components/style/values/computed/column.rs +++ b/components/style/values/computed/column.rs @@ -4,8 +4,8 @@ //! Computed types for the column properties. -use values::computed::PositiveInteger; -use values::generics::column::ColumnCount as GenericColumnCount; +use crate::values::computed::PositiveInteger; +use crate::values::generics::column::ColumnCount as GenericColumnCount; /// A computed type for `column-count` values. pub type ColumnCount = GenericColumnCount<PositiveInteger>; diff --git a/components/style/values/computed/counters.rs b/components/style/values/computed/counters.rs index 211ca6753e7..189eb0fe0ae 100644 --- a/components/style/values/computed/counters.rs +++ b/components/style/values/computed/counters.rs @@ -4,10 +4,10 @@ //! Computed values for counter properties -use values::computed::url::ComputedImageUrl; -use values::generics::counters as generics; -use values::generics::counters::CounterIncrement as GenericCounterIncrement; -use values::generics::counters::CounterReset as GenericCounterReset; +use crate::values::computed::url::ComputedImageUrl; +use crate::values::generics::counters as generics; +use crate::values::generics::counters::CounterIncrement as GenericCounterIncrement; +use crate::values::generics::counters::CounterReset as GenericCounterReset; /// A computed value for the `counter-increment` property. pub type CounterIncrement = GenericCounterIncrement<i32>; diff --git a/components/style/values/computed/easing.rs b/components/style/values/computed/easing.rs index 394cf3ea41e..09d325aa9da 100644 --- a/components/style/values/computed/easing.rs +++ b/components/style/values/computed/easing.rs @@ -4,8 +4,8 @@ //! Computed types for CSS Easing functions. -use values::computed::{Integer, Number}; -use values::generics::easing; +use crate::values::computed::{Integer, Number}; +use crate::values::generics::easing; /// A computed timing function. pub type ComputedTimingFunction = easing::TimingFunction<Integer, Number>; diff --git a/components/style/values/computed/effects.rs b/components/style/values/computed/effects.rs index 9a511c4fd89..5608327b642 100644 --- a/components/style/values/computed/effects.rs +++ b/components/style/values/computed/effects.rs @@ -4,16 +4,16 @@ //! Computed types for CSS values related to effects. -use values::computed::color::Color; -use values::computed::length::{Length, NonNegativeLength}; +use crate::values::computed::color::Color; +use crate::values::computed::length::{Length, NonNegativeLength}; +use crate::values::computed::{Angle, NonNegativeNumber}; +use crate::values::generics::effects::BoxShadow as GenericBoxShadow; +use crate::values::generics::effects::Filter as GenericFilter; +use crate::values::generics::effects::SimpleShadow as GenericSimpleShadow; +#[cfg(not(feature = "gecko"))] +use crate::values::Impossible; #[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<Color, Length, NonNegativeLength, Length>; diff --git a/components/style/values/computed/flex.rs b/components/style/values/computed/flex.rs index e70173d66c6..87ebf00d3c5 100644 --- a/components/style/values/computed/flex.rs +++ b/components/style/values/computed/flex.rs @@ -4,11 +4,11 @@ //! Computed types for CSS values related to flexbox. -use values::generics::flex::FlexBasis as GenericFlexBasis; +use crate::values::generics::flex::FlexBasis as GenericFlexBasis; /// The `width` value type. #[cfg(feature = "servo")] -pub type Width = ::values::computed::NonNegativeLengthOrPercentageOrAuto; +pub type Width = crate::values::computed::NonNegativeLengthOrPercentageOrAuto; /// The `width` value type. #[cfg(feature = "gecko")] diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs index 27a8fad133d..89c3e56ec2a 100644 --- a/components/style/values/computed/font.rs +++ b/components/style/values/computed/font.rs @@ -6,6 +6,16 @@ use app_units::Au; use byteorder::{BigEndian, ByteOrder}; +use crate::values::animated::{ToAnimatedValue, ToAnimatedZero}; +use crate::values::computed::{Angle, Context, Integer, NonNegativeLength, NonNegativePercentage}; +use crate::values::computed::{Number, Percentage, ToComputedValue}; +use crate::values::generics::font::{ + self as generics, FeatureTagValue, FontSettings, VariationValue, +}; +use crate::values::specified::font::{self as specified, MAX_FONT_WEIGHT, MIN_FONT_WEIGHT}; +use crate::values::specified::length::{FontBaseSize, NoCalcLength}; +use crate::values::CSSFloat; +use crate::Atom; use cssparser::{serialize_identifier, CssStringWriter, Parser}; #[cfg(feature = "gecko")] use gecko_bindings::sugar::refptr::RefPtr; @@ -18,17 +28,11 @@ use std::hash::{Hash, Hasher}; #[cfg(feature = "servo")] use std::slice; use style_traits::{CssWriter, ParseError, ToCss}; -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, 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}; + +pub use crate::values::computed::Length as MozScriptMinSize; +pub use crate::values::specified::font::{ + FontSynthesis, MozScriptSizeMultiplier, XLang, XTextZoom, +}; /// A value for the font-weight property per: /// @@ -370,7 +374,7 @@ impl SingleFontFamily { /// Parse a font-family value pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { - if let Ok(value) = input.try(|i| i.expect_string_cloned()) { + if let Ok(value) = input.r#try(|i| i.expect_string_cloned()) { return Ok(SingleFontFamily::FamilyName(FamilyName { name: Atom::from(&*value), syntax: FamilyNameSyntax::Quoted, @@ -415,7 +419,7 @@ impl SingleFontFamily { value.push(' '); value.push_str(&ident); } - while let Ok(ident) = input.try(|i| i.expect_ident_cloned()) { + while let Ok(ident) = input.r#try(|i| i.expect_ident_cloned()) { value.push(' '); value.push_str(&ident); } diff --git a/components/style/values/computed/image.rs b/components/style/values/computed/image.rs index c89871f6cfb..ea311234185 100644 --- a/components/style/values/computed/image.rs +++ b/components/style/values/computed/image.rs @@ -7,19 +7,19 @@ //! //! [image]: https://drafts.csswg.org/css-images/#image-values +use crate::values::computed::position::Position; +use crate::values::computed::url::ComputedImageUrl; +use crate::values::computed::{Angle, Color, Context}; +use crate::values::computed::{Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue}; +use crate::values::generics::image::{self as generic, CompatMode}; +use crate::values::specified::image::LineDirection as SpecifiedLineDirection; +use crate::values::specified::position::{X, Y}; +use crate::values::{Either, None_}; use std::f32::consts::PI; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -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<None_, Image>; diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 3a3242a386b..4c7fe16dcfc 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -6,22 +6,24 @@ use super::{Context, Number, Percentage, ToComputedValue}; use app_units::Au; +use crate::values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use crate::values::generics::length::{ + MaxLength as GenericMaxLength, MozLength as GenericMozLength, +}; +use crate::values::generics::NonNegative; +use crate::values::specified::length::ViewportPercentageLength; +use crate::values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength}; +use crate::values::{specified, Auto, CSSFloat, Either, IsAuto, Normal}; use ordered_float::NotNan; use std::fmt::{self, Write}; use std::ops::{Add, Neg}; use style_traits::values::specified::AllowedNumericType; use style_traits::{CssWriter, ToCss}; -use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; -use values::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::generics::length::{MaxLength as GenericMaxLength, MozLength as GenericMozLength}; -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; -pub use values::specified::{Angle, BorderStyle, Time}; +pub use crate::values::specified::url::UrlOrNone; +pub use crate::values::specified::{Angle, BorderStyle, Time}; impl ToComputedValue for specified::NoCalcLength { type ComputedValue = CSSPixelLength; diff --git a/components/style/values/computed/list.rs b/components/style/values/computed/list.rs index ec71a823828..ebbd1566310 100644 --- a/components/style/values/computed/list.rs +++ b/components/style/values/computed/list.rs @@ -4,9 +4,9 @@ //! `list` computed values. +pub use crate::values::specified::list::{QuotePair, Quotes}; #[cfg(feature = "gecko")] pub use values::specified::list::ListStyleType; -pub use values::specified::list::{QuotePair, Quotes}; use servo_arc::Arc; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 0cf1dac5686..3543e227f78 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -11,23 +11,23 @@ use super::generics::grid::{TrackList as GenericTrackList, TrackSize as GenericT use super::generics::{GreaterThanOrEqualToOne, NonNegative}; use super::specified; use super::{CSSFloat, CSSInteger}; -use context::QuirksMode; +use crate::context::QuirksMode; +use crate::font_metrics::{get_metrics_provider_for_product, FontMetricsProvider}; +use crate::media_queries::Device; +use crate::properties::{ComputedValues, LonghandId, StyleBuilder}; +use crate::rule_cache::RuleCacheConditions; +use crate::Atom; +#[cfg(feature = "servo")] +use crate::Prefix; use euclid::Size2D; -use font_metrics::{get_metrics_provider_for_product, FontMetricsProvider}; -use media_queries::Device; #[cfg(feature = "gecko")] use properties; -use properties::{ComputedValues, LonghandId, StyleBuilder}; -use rule_cache::RuleCacheConditions; use std::cell::RefCell; use std::cmp; use std::f32; use std::fmt::{self, Write}; use style_traits::cursor::CursorKind; use style_traits::{CssWriter, ToCss}; -use Atom; -#[cfg(feature = "servo")] -use Prefix; #[cfg(feature = "gecko")] pub use self::align::{AlignContent, AlignItems, JustifyContent, JustifyItems, SelfAlignment}; diff --git a/components/style/values/computed/motion.rs b/components/style/values/computed/motion.rs index 352363ab491..974495a6ff9 100644 --- a/components/style/values/computed/motion.rs +++ b/components/style/values/computed/motion.rs @@ -7,4 +7,4 @@ /// A computed offset-path. The computed value is as specified value. /// /// https://drafts.fxtf.org/motion-1/#offset-path-property -pub use values::specified::motion::OffsetPath; +pub use crate::values::specified::motion::OffsetPath; diff --git a/components/style/values/computed/outline.rs b/components/style/values/computed/outline.rs index b3fcaee40e6..b0a076650cb 100644 --- a/components/style/values/computed/outline.rs +++ b/components/style/values/computed/outline.rs @@ -4,4 +4,4 @@ //! Computed values for outline properties -pub use values::specified::OutlineStyle; +pub use crate::values::specified::OutlineStyle; diff --git a/components/style/values/computed/percentage.rs b/components/style/values/computed/percentage.rs index 9f5cd02abbe..d4a4ad8b327 100644 --- a/components/style/values/computed/percentage.rs +++ b/components/style/values/computed/percentage.rs @@ -4,11 +4,11 @@ //! Computed percentages. +use crate::values::animated::ToAnimatedValue; +use crate::values::generics::NonNegative; +use crate::values::{serialize_percentage, CSSFloat}; use std::fmt; use style_traits::{CssWriter, ToCss}; -use values::animated::ToAnimatedValue; -use values::generics::NonNegative; -use values::{serialize_percentage, CSSFloat}; /// A computed percentage. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] diff --git a/components/style/values/computed/position.rs b/components/style/values/computed/position.rs index eae5161cd05..1828e8afd44 100644 --- a/components/style/values/computed/position.rs +++ b/components/style/values/computed/position.rs @@ -7,12 +7,12 @@ //! //! [position]: https://drafts.csswg.org/css-backgrounds-3/#position +use crate::values::computed::{Integer, LengthOrPercentage, Percentage}; +use crate::values::generics::position::Position as GenericPosition; +use crate::values::generics::position::ZIndex as GenericZIndex; +pub use crate::values::specified::position::{GridAutoFlow, GridTemplateAreas}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::computed::{Integer, LengthOrPercentage, Percentage}; -use values::generics::position::Position as GenericPosition; -use values::generics::position::ZIndex as GenericZIndex; -pub use values::specified::position::{GridAutoFlow, GridTemplateAreas}; /// The computed value of a CSS `<position>` pub type Position = GenericPosition<HorizontalPosition, VerticalPosition>; diff --git a/components/style/values/computed/rect.rs b/components/style/values/computed/rect.rs index 46fcdc65583..268e090dcbc 100644 --- a/components/style/values/computed/rect.rs +++ b/components/style/values/computed/rect.rs @@ -4,8 +4,8 @@ //! Computed types for CSS borders. -use values::computed::length::LengthOrNumber; -use values::generics::rect::Rect; +use crate::values::computed::length::LengthOrNumber; +use crate::values::generics::rect::Rect; /// A specified rectangle made of four `<length-or-number>` values. pub type LengthOrNumberRect = Rect<LengthOrNumber>; diff --git a/components/style/values/computed/resolution.rs b/components/style/values/computed/resolution.rs index 9d743f9cbf3..5e4d9dc245f 100644 --- a/components/style/values/computed/resolution.rs +++ b/components/style/values/computed/resolution.rs @@ -6,11 +6,11 @@ //! //! https://drafts.csswg.org/css-values/#resolution +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::specified; +use crate::values::CSSFloat; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::computed::{Context, ToComputedValue}; -use values::specified; -use values::CSSFloat; /// A computed `<resolution>`. pub struct Resolution(CSSFloat); diff --git a/components/style/values/computed/svg.rs b/components/style/values/computed/svg.rs index 9428ce60bae..d04f7331fb0 100644 --- a/components/style/values/computed/svg.rs +++ b/components/style/values/computed/svg.rs @@ -4,16 +4,16 @@ //! Computed types for SVG properties. -use values::computed::color::Color; -use values::computed::url::ComputedUrl; -use values::computed::{LengthOrPercentage, NonNegativeLengthOrPercentage}; -use values::computed::{NonNegativeNumber, Number, Opacity}; -use values::generics::svg as generic; -use values::RGBA; +use crate::values::computed::color::Color; +use crate::values::computed::url::ComputedUrl; +use crate::values::computed::{LengthOrPercentage, NonNegativeLengthOrPercentage}; +use crate::values::computed::{NonNegativeNumber, Number, Opacity}; +use crate::values::generics::svg as generic; +use crate::values::RGBA; -pub use values::specified::SVGPaintOrder; +pub use crate::values::specified::SVGPaintOrder; -pub use values::specified::MozContextProperties; +pub use crate::values::specified::MozContextProperties; /// Computed SVG Paint value pub type SVGPaint = generic::SVGPaint<Color, ComputedUrl>; @@ -83,7 +83,7 @@ pub type SVGWidth = generic::SVGLength<NonNegativeSvgLengthOrPercentageOrNumber> impl SVGWidth { /// `1px`. pub fn one() -> Self { - use values::generics::NonNegative; + use crate::values::generics::NonNegative; generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::LengthOrPercentage( NonNegative(LengthOrPercentage::one()), )) diff --git a/components/style/values/computed/table.rs b/components/style/values/computed/table.rs index da44de8aae5..2378adb6e37 100644 --- a/components/style/values/computed/table.rs +++ b/components/style/values/computed/table.rs @@ -4,4 +4,4 @@ //! Computed types for table properties. -pub use values::specified::table::XSpan; +pub use crate::values::specified::table::XSpan; diff --git a/components/style/values/computed/text.rs b/components/style/values/computed/text.rs index f8443ec607a..0f16f2d26fd 100644 --- a/components/style/values/computed/text.rs +++ b/components/style/values/computed/text.rs @@ -5,20 +5,22 @@ //! Computed types for text properties. #[cfg(feature = "servo")] -use properties::StyleBuilder; +use crate::properties::StyleBuilder; +use crate::values::computed::length::{Length, LengthOrPercentage}; +use crate::values::computed::{NonNegativeLength, NonNegativeNumber}; +use crate::values::generics::text::InitialLetter as GenericInitialLetter; +use crate::values::generics::text::LineHeight as GenericLineHeight; +use crate::values::generics::text::MozTabSize as GenericMozTabSize; +use crate::values::generics::text::Spacing; +use crate::values::specified::text::{ + TextEmphasisFillMode, TextEmphasisShapeKeyword, TextOverflowSide, +}; +use crate::values::{CSSFloat, CSSInteger}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -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; + +pub use crate::values::specified::TextAlignKeyword as TextAlign; +pub use crate::values::specified::TextEmphasisPosition; /// A computed value for the `initial-letter` property. pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>; @@ -99,7 +101,7 @@ impl TextDecorationsInEffect { /// Computes the text-decorations in effect for a given style. #[cfg(feature = "servo")] pub fn from_style(style: &StyleBuilder) -> Self { - use values::computed::Display; + use crate::values::computed::Display; // Start with no declarations if this is an atomic inline-level box; // otherwise, start with the declarations in effect and add in the text diff --git a/components/style/values/computed/time.rs b/components/style/values/computed/time.rs index 621420258ea..270e3a402d8 100644 --- a/components/style/values/computed/time.rs +++ b/components/style/values/computed/time.rs @@ -4,9 +4,9 @@ //! Computed time values. +use crate::values::CSSFloat; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::CSSFloat; /// A computed `<time>` value. #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd)] diff --git a/components/style/values/computed/transform.rs b/components/style/values/computed/transform.rs index e937b95c77f..079c1e2535b 100644 --- a/components/style/values/computed/transform.rs +++ b/components/style/values/computed/transform.rs @@ -5,13 +5,13 @@ //! Computed types for CSS values that are related to transformations. use super::CSSFloat; +use crate::values::animated::ToAnimatedZero; +use crate::values::computed::{Angle, Integer, Length, LengthOrPercentage, Number, Percentage}; +use crate::values::generics::transform as generic; use euclid::{Transform3D, Vector3D}; use num_traits::Zero; -use values::animated::ToAnimatedZero; -use values::computed::{Angle, Integer, Length, LengthOrPercentage, Number, Percentage}; -use values::generics::transform as generic; -pub use values::generics::transform::TransformStyle; +pub use crate::values::generics::transform::TransformStyle; /// A single operation in a computed CSS `transform` pub type TransformOperation = diff --git a/components/style/values/computed/ui.rs b/components/style/values/computed/ui.rs index cf1d953fd26..57990d84d79 100644 --- a/components/style/values/computed/ui.rs +++ b/components/style/values/computed/ui.rs @@ -4,13 +4,13 @@ //! Computed values for UI properties -use values::computed::color::Color; -use values::computed::url::ComputedImageUrl; -use values::computed::Number; -use values::generics::ui as generics; -use values::{Auto, Either}; +use crate::values::computed::color::Color; +use crate::values::computed::url::ComputedImageUrl; +use crate::values::computed::Number; +use crate::values::generics::ui as generics; +use crate::values::{Auto, Either}; -pub use values::specified::ui::MozForceBrokenImageIcon; +pub use crate::values::specified::ui::MozForceBrokenImageIcon; /// auto | <color> pub type ColorOrAuto = Either<Color, Auto>; diff --git a/components/style/values/computed/url.rs b/components/style/values/computed/url.rs index aca5d301fd2..74978fd5201 100644 --- a/components/style/values/computed/url.rs +++ b/components/style/values/computed/url.rs @@ -4,12 +4,12 @@ //! Common handling for the computed value CSS url() values. -use values::generics::url::UrlOrNone as GenericUrlOrNone; +use crate::values::generics::url::UrlOrNone as GenericUrlOrNone; +#[cfg(feature = "servo")] +pub use crate::servo::url::{ComputedImageUrl, ComputedUrl}; #[cfg(feature = "gecko")] pub use gecko::url::{ComputedImageUrl, ComputedUrl}; -#[cfg(feature = "servo")] -pub use servo::url::{ComputedImageUrl, ComputedUrl}; /// Computed <url> | <none> pub type UrlOrNone = GenericUrlOrNone<ComputedUrl>; diff --git a/components/style/values/generics/basic_shape.rs b/components/style/values/generics/basic_shape.rs index f571d488a8e..9245ef7eb12 100644 --- a/components/style/values/generics/basic_shape.rs +++ b/components/style/values/generics/basic_shape.rs @@ -5,14 +5,14 @@ //! CSS handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape) //! types that are generic over their `ToCss` implementations. +use crate::values::animated::{Animate, Procedure, ToAnimatedZero}; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use crate::values::generics::border::BorderRadius; +use crate::values::generics::position::Position; +use crate::values::generics::rect::Rect; +use crate::values::specified::SVGPathData; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::animated::{Animate, Procedure, ToAnimatedZero}; -use values::distance::{ComputeSquaredDistance, SquaredDistance}; -use values::generics::border::BorderRadius; -use values::generics::position::Position; -use values::generics::rect::Rect; -use values::specified::SVGPathData; /// A clipping shape, for `clip-path`. pub type ClippingShape<BasicShape, Url> = ShapeSource<BasicShape, GeometryBox, Url>; diff --git a/components/style/values/generics/border.rs b/components/style/values/generics/border.rs index 4f40409843a..26a4246f525 100644 --- a/components/style/values/generics/border.rs +++ b/components/style/values/generics/border.rs @@ -4,10 +4,10 @@ //! Generic types for CSS values related to borders. +use crate::values::generics::rect::Rect; +use crate::values::generics::size::Size; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::generics::rect::Rect; -use values::generics::size::Size; /// A generic value for a single side of a `border-image-width` property. #[derive( diff --git a/components/style/values/generics/box.rs b/components/style/values/generics/box.rs index 0b525974288..b34556718dd 100644 --- a/components/style/values/generics/box.rs +++ b/components/style/values/generics/box.rs @@ -4,7 +4,7 @@ //! Generic types for box properties. -use values::animated::ToAnimatedZero; +use crate::values::animated::ToAnimatedZero; /// A generic value for the `vertical-align` property. #[derive( diff --git a/components/style/values/generics/counters.rs b/components/style/values/generics/counters.rs index a5990691336..ee790d0050b 100644 --- a/components/style/values/generics/counters.rs +++ b/components/style/values/generics/counters.rs @@ -5,13 +5,13 @@ //! Generic types for counters-related CSS values. #[cfg(feature = "servo")] -use computed_values::list_style_type::T as ListStyleType; +use crate::computed_values::list_style_type::T as ListStyleType; +use crate::values::CustomIdent; use std::ops::Deref; #[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/components/style/values/generics/easing.rs b/components/style/values/generics/easing.rs index 616fd63d172..96c4ad8ebd3 100644 --- a/components/style/values/generics/easing.rs +++ b/components/style/values/generics/easing.rs @@ -5,8 +5,8 @@ //! Generic types for CSS Easing Functions. //! https://drafts.csswg.org/css-easing/#timing-functions -use parser::ParserContext; -use values::CSSFloat; +use crate::parser::ParserContext; +use crate::values::CSSFloat; /// A generic easing function. #[derive( diff --git a/components/style/values/generics/font.rs b/components/style/values/generics/font.rs index fa1e160273c..204de699db3 100644 --- a/components/style/values/generics/font.rs +++ b/components/style/values/generics/font.rs @@ -6,9 +6,9 @@ use app_units::Au; use byteorder::{BigEndian, ReadBytesExt}; +use crate::parser::{Parse, ParserContext}; use cssparser::Parser; use num_traits::One; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use std::io::Cursor; use style_traits::{CssWriter, KeywordsCollectFn, ParseError}; @@ -85,7 +85,7 @@ impl<T: Parse> Parse for FontSettings<T> { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("normal")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("normal")).is_ok() { return Ok(Self::normal()); } diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs index fda0c3a0759..c565ca6c320 100644 --- a/components/style/values/generics/grid.rs +++ b/components/style/values/generics/grid.rs @@ -5,15 +5,15 @@ //! Generic types for the handling of //! [grids](https://drafts.csswg.org/css-grid/). +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::specified; +use crate::values::specified::grid::parse_line_names; +use crate::values::{CSSFloat, CustomIdent}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use std::{mem, usize}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use values::computed::{Context, ToComputedValue}; -use values::specified; -use values::specified::grid::parse_line_names; -use values::{CSSFloat, CustomIdent}; /// A `<grid-line>` type. /// @@ -86,7 +86,7 @@ impl Parse for GridLine<specified::Integer> { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let mut grid_line = Self::auto(); - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("auto")).is_ok() { return Ok(grid_line); } @@ -99,7 +99,7 @@ impl Parse for GridLine<specified::Integer> { for _ in 0..3 { // Maximum possible entities for <grid-line> let location = input.current_source_location(); - if input.try(|i| i.expect_ident_matching("span")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("span")).is_ok() { if grid_line.is_span { return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } @@ -109,14 +109,14 @@ impl Parse for GridLine<specified::Integer> { } grid_line.is_span = true; - } else if let Ok(i) = input.try(|i| specified::Integer::parse(context, i)) { + } else if let Ok(i) = input.r#try(|i| specified::Integer::parse(context, i)) { // FIXME(emilio): Probably shouldn't reject if it's calc()... if i.value() == 0 || val_before_span || grid_line.line_num.is_some() { return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } grid_line.line_num = Some(i); - } else if let Ok(name) = input.try(|i| i.expect_ident_cloned()) { + } else if let Ok(name) = input.r#try(|i| i.expect_ident_cloned()) { if val_before_span || grid_line.ident.is_some() { return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } @@ -375,7 +375,7 @@ impl Parse for RepeatCount<specified::Integer> { ) -> Result<Self, ParseError<'i>> { // Maximum number of repeat is 10000. The greater numbers should be clamped. const MAX_LINE: i32 = 10000; - if let Ok(mut i) = input.try(|i| specified::Integer::parse_positive(context, i)) { + if let Ok(mut i) = input.r#try(|i| specified::Integer::parse_positive(context, i)) { if i.value() > MAX_LINE { i = specified::Integer::new(MAX_LINE); } @@ -605,14 +605,14 @@ impl Parse for LineNameList { let mut fill_idx = None; loop { - let repeat_parse_result = input.try(|input| { + let repeat_parse_result = input.r#try(|input| { input.expect_function_matching("repeat")?; input.parse_nested_block(|input| { let count = RepeatCount::parse(context, input)?; input.expect_comma()?; let mut names_list = vec![]; names_list.push(parse_line_names(input)?); // there should be at least one - while let Ok(names) = input.try(parse_line_names) { + while let Ok(names) = input.r#try(parse_line_names) { names_list.push(names); } @@ -643,7 +643,7 @@ impl Parse for LineNameList { }, _ => return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)), } - } else if let Ok(names) = input.try(parse_line_names) { + } else if let Ok(names) = input.r#try(parse_line_names) { line_names.push(names); } else { break; diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index 9ce60d3362c..8e962389d9a 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -6,12 +6,12 @@ //! //! [images]: https://drafts.csswg.org/css-images/#image-values -use custom_properties; +use crate::custom_properties; +use crate::values::serialize_atom_identifier; +use crate::Atom; 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/components/style/values/generics/length.rs b/components/style/values/generics/length.rs index 15832b4616d..efabbdee7c9 100644 --- a/components/style/values/generics/length.rs +++ b/components/style/values/generics/length.rs @@ -4,7 +4,7 @@ //! Generic types for CSS values related to length. -use values::computed::ExtremumLength; +use crate::values::computed::ExtremumLength; /// A generic value for the `width`, `height`, `min-width`, or `min-height` property. /// diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index 0f13cfcdd2f..f18a8d35e5d 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -6,9 +6,9 @@ //! for both specified and computed values. use super::CustomIdent; -use counter_style::{parse_counter_style_name, Symbols}; +use crate::counter_style::{parse_counter_style_name, Symbols}; +use crate::parser::{Parse, ParserContext}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::{KeywordsCollectFn, ParseError}; use style_traits::{SpecifiedValueInfo, StyleParseErrorKind}; @@ -111,16 +111,19 @@ impl Parse for CounterStyleOrNone { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(name) = input.try(|i| parse_counter_style_name(i)) { + if let Ok(name) = input.r#try(|i| parse_counter_style_name(i)) { return Ok(CounterStyleOrNone::Name(name)); } - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(CounterStyleOrNone::None); } - if input.try(|i| i.expect_function_matching("symbols")).is_ok() { + if input + .r#try(|i| i.expect_function_matching("symbols")) + .is_ok() + { return input.parse_nested_block(|input| { let symbols_type = input - .try(|i| SymbolsType::parse(i)) + .r#try(|i| SymbolsType::parse(i)) .unwrap_or(SymbolsType::Symbolic); let symbols = Symbols::parse(context, input)?; // There must be at least two symbols for alphabetic or diff --git a/components/style/values/generics/rect.rs b/components/style/values/generics/rect.rs index 510cb75a6f8..6ba11570dfe 100644 --- a/components/style/values/generics/rect.rs +++ b/components/style/values/generics/rect.rs @@ -4,8 +4,8 @@ //! Generic types for CSS values that are composed of four sides. +use crate::parser::{Parse, ParserContext}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, ToCss}; @@ -50,7 +50,7 @@ where Parse: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>, { let first = parse(context, input)?; - let second = if let Ok(second) = input.try(|i| parse(context, i)) { + let second = if let Ok(second) = input.r#try(|i| parse(context, i)) { second } else { // <first> @@ -61,13 +61,13 @@ where first, )); }; - let third = if let Ok(third) = input.try(|i| parse(context, i)) { + let third = if let Ok(third) = input.r#try(|i| parse(context, i)) { third } else { // <first> <second> return Ok(Self::new(first.clone(), second.clone(), first, second)); }; - let fourth = if let Ok(fourth) = input.try(|i| parse(context, i)) { + let fourth = if let Ok(fourth) = input.r#try(|i| parse(context, i)) { fourth } else { // <first> <second> <third> diff --git a/components/style/values/generics/size.rs b/components/style/values/generics/size.rs index d7ef5810f05..24fba15d59c 100644 --- a/components/style/values/generics/size.rs +++ b/components/style/values/generics/size.rs @@ -4,12 +4,12 @@ //! Generic type for CSS properties that are composed by two dimensions. +use crate::parser::ParserContext; +use crate::values::animated::ToAnimatedValue; use cssparser::Parser; use euclid::Size2D; -use parser::ParserContext; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss}; -use values::animated::ToAnimatedValue; /// A generic size, for `border-*-radius` longhand properties, or /// `border-spacing`. @@ -55,7 +55,7 @@ impl<L> Size<L> { { let first = parse_one(context, input)?; let second = input - .try(|i| parse_one(context, i)) + .r#try(|i| parse_one(context, i)) .unwrap_or_else(|_| first.clone()); Ok(Self::new(first, second)) } diff --git a/components/style/values/generics/svg.rs b/components/style/values/generics/svg.rs index 2dd81da5eda..cdbca333441 100644 --- a/components/style/values/generics/svg.rs +++ b/components/style/values/generics/svg.rs @@ -4,10 +4,10 @@ //! Generic types for CSS values in SVG +use crate::parser::{Parse, ParserContext}; +use crate::values::{Either, None_}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::{ParseError, StyleParseErrorKind}; -use values::{Either, None_}; /// An SVG paint value /// @@ -84,10 +84,10 @@ fn parse_fallback<'i, 't, ColorType: Parse>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Option<Either<ColorType, None_>> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { Some(Either::Second(None_)) } else { - if let Ok(color) = input.try(|i| ColorType::parse(context, i)) { + if let Ok(color) = input.r#try(|i| ColorType::parse(context, i)) { Some(Either::First(color)) } else { None @@ -100,12 +100,12 @@ impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlP context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(url) = input.try(|i| UrlPaintServer::parse(context, i)) { + if let Ok(url) = input.r#try(|i| UrlPaintServer::parse(context, i)) { Ok(SVGPaint { kind: SVGPaintKind::PaintServer(url), fallback: parse_fallback(context, input), }) - } else if let Ok(kind) = input.try(SVGPaintKind::parse_ident) { + } else if let Ok(kind) = input.r#try(SVGPaintKind::parse_ident) { if let SVGPaintKind::None = kind { Ok(SVGPaint { kind: kind, @@ -117,7 +117,7 @@ impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlP fallback: parse_fallback(context, input), }) } - } else if let Ok(color) = input.try(|i| ColorType::parse(context, i)) { + } else if let Ok(color) = input.r#try(|i| ColorType::parse(context, i)) { Ok(SVGPaint { kind: SVGPaintKind::Color(color), fallback: None, @@ -158,7 +158,7 @@ impl<LengthOrPercentageType: Parse, NumberType: Parse> Parse context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(num) = input.try(|i| NumberType::parse(context, i)) { + if let Ok(num) = input.r#try(|i| NumberType::parse(context, i)) { return Ok(SvgLengthOrPercentageOrNumber::Number(num)); } diff --git a/components/style/values/generics/text.rs b/components/style/values/generics/text.rs index e85c444a695..0be499c6933 100644 --- a/components/style/values/generics/text.rs +++ b/components/style/values/generics/text.rs @@ -5,11 +5,11 @@ //! Generic types for text properties. use app_units::Au; +use crate::parser::ParserContext; +use crate::values::animated::{Animate, Procedure, ToAnimatedZero}; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; use cssparser::Parser; -use parser::ParserContext; use style_traits::ParseError; -use values::animated::{Animate, Procedure, ToAnimatedZero}; -use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// A generic value for the `initial-letter` property. #[derive( @@ -58,7 +58,7 @@ impl<Value> Spacing<Value> { where F: FnOnce(&ParserContext, &mut Parser<'i, 't>) -> Result<Value, ParseError<'i>>, { - if input.try(|i| i.expect_ident_matching("normal")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("normal")).is_ok() { return Ok(Spacing::Normal); } parse(context, input).map(Spacing::Value) diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index 1eb46b0bd1d..c48c37e552a 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -5,16 +5,16 @@ //! Generic types for CSS values that are related to transformations. use app_units::Au; +use crate::values::computed::length::Length as ComputedLength; +use crate::values::computed::length::LengthOrPercentage as ComputedLengthOrPercentage; +use crate::values::specified::angle::Angle as SpecifiedAngle; +use crate::values::specified::length::Length as SpecifiedLength; +use crate::values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage; +use crate::values::{computed, CSSFloat}; use euclid::{self, Rect, Transform3D}; use num_traits::Zero; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -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)] @@ -514,8 +514,8 @@ pub fn get_normalized_vector_and_angle<T: Zero>( z: CSSFloat, angle: T, ) -> (CSSFloat, CSSFloat, CSSFloat, T) { + use crate::values::computed::transform::DirectionVector; use euclid::approxeq::ApproxEq; - use values::computed::transform::DirectionVector; let vector = DirectionVector::new(x, y, z); if vector.square_length().approx_eq(&f32::zero()) { // https://www.w3.org/TR/css-transforms-1/#funcdef-rotate3d diff --git a/components/style/values/generics/url.rs b/components/style/values/generics/url.rs index ff9fa16d665..ccd50b235b9 100644 --- a/components/style/values/generics/url.rs +++ b/components/style/values/generics/url.rs @@ -4,8 +4,8 @@ //! Generic types for url properties. +use crate::parser::{Parse, ParserContext}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::ParseError; /// An image url or none, used for example in list-style-image @@ -44,7 +44,7 @@ where context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<UrlOrNone<Url>, ParseError<'i>> { - if let Ok(url) = input.try(|input| Url::parse(context, input)) { + if let Ok(url) = input.r#try(|input| Url::parse(context, input)) { return Ok(UrlOrNone::Url(url)); } input.expect_ident_matching("none")?; diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index 6d2dd1c2b3a..4e4d1cf0a55 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -10,18 +10,18 @@ pub use cssparser::{serialize_identifier, serialize_name, CowRcStr, Parser}; pub use cssparser::{SourceLocation, Token, RGBA}; -use parser::{Parse, ParserContext}; +use crate::Atom; +use crate::parser::{Parse, ParserContext}; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; 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 crate::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; @@ -155,7 +155,7 @@ impl<A: Parse, B: Parse> Parse for Either<A, B> { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Either<A, B>, ParseError<'i>> { - if let Ok(v) = input.try(|i| A::parse(context, i)) { + if let Ok(v) = input.r#try(|i| A::parse(context, i)) { Ok(Either::First(v)) } else { B::parse(context, input).map(Either::Second) diff --git a/components/style/values/specified/angle.rs b/components/style/values/specified/angle.rs index 01c86aab180..6c799d9cab2 100644 --- a/components/style/values/specified/angle.rs +++ b/components/style/values/specified/angle.rs @@ -4,15 +4,15 @@ //! Specified angles. +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::angle::Angle as ComputedAngle; +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::specified::calc::CalcNode; +use crate::values::CSSFloat; use cssparser::{Parser, Token}; -use parser::{Parse, ParserContext}; use std::f32::consts::PI; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss}; -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))] diff --git a/components/style/values/specified/background.rs b/components/style/values/specified/background.rs index 6c85d6ec5a6..29e1812dbbc 100644 --- a/components/style/values/specified/background.rs +++ b/components/style/values/specified/background.rs @@ -4,12 +4,12 @@ //! Specified types for CSS values related to backgrounds. +use crate::parser::{Parse, ParserContext}; +use crate::values::generics::background::BackgroundSize as GenericBackgroundSize; +use crate::values::specified::length::NonNegativeLengthOrPercentageOrAuto; use cssparser::Parser; -use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use style_traits::ParseError; -use values::generics::background::BackgroundSize as GenericBackgroundSize; -use values::specified::length::NonNegativeLengthOrPercentageOrAuto; /// A specified value for the `background-size` property. pub type BackgroundSize = GenericBackgroundSize<NonNegativeLengthOrPercentageOrAuto>; @@ -19,9 +19,9 @@ impl Parse for BackgroundSize { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(width) = input.try(|i| NonNegativeLengthOrPercentageOrAuto::parse(context, i)) { + if let Ok(width) = input.r#try(|i| NonNegativeLengthOrPercentageOrAuto::parse(context, i)) { let height = input - .try(|i| NonNegativeLengthOrPercentageOrAuto::parse(context, i)) + .r#try(|i| NonNegativeLengthOrPercentageOrAuto::parse(context, i)) .unwrap_or(NonNegativeLengthOrPercentageOrAuto::auto()); return Ok(GenericBackgroundSize::Explicit { width, height }); } @@ -106,7 +106,7 @@ impl Parse for BackgroundRepeat { }, }; - let vertical = input.try(BackgroundRepeatKeyword::parse).ok(); + let vertical = input.r#try(BackgroundRepeatKeyword::parse).ok(); Ok(BackgroundRepeat::Keywords(horizontal, vertical)) } } diff --git a/components/style/values/specified/basic_shape.rs b/components/style/values/specified/basic_shape.rs index 9470311b7a9..4551b5e71d5 100644 --- a/components/style/values/specified/basic_shape.rs +++ b/components/style/values/specified/basic_shape.rs @@ -7,26 +7,26 @@ //! //! [basic-shape]: https://drafts.csswg.org/css-shapes/#typedef-basic-shape +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::Percentage; +use crate::values::generics::basic_shape as generic; +use crate::values::generics::basic_shape::{GeometryBox, Path, PolygonCoord}; +use crate::values::generics::basic_shape::{ShapeBox, ShapeSource}; +use crate::values::generics::rect::Rect; +use crate::values::specified::border::BorderRadius; +use crate::values::specified::image::Image; +use crate::values::specified::position::{HorizontalPosition, Position, PositionComponent}; +use crate::values::specified::position::{Side, VerticalPosition}; +use crate::values::specified::url::SpecifiedUrl; +use crate::values::specified::LengthOrPercentage; +use crate::values::specified::SVGPathData; use cssparser::Parser; -use parser::{Parse, ParserContext}; use std::borrow::Cow; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use values::computed::Percentage; -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::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; +pub use crate::values::generics::basic_shape::FillRule; /// A specified clipping shape. pub type ClippingShape = generic::ClippingShape<BasicShape, SpecifiedUrl>; @@ -70,12 +70,12 @@ impl Parse for ClippingShape { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if is_clip_path_path_enabled(context) { - if let Ok(p) = input.try(|i| Path::parse(context, i)) { + if let Ok(p) = input.r#try(|i| Path::parse(context, i)) { return Ok(ShapeSource::Path(p)); } } - if let Ok(url) = input.try(|i| SpecifiedUrl::parse(context, i)) { + if let Ok(url) = input.r#try(|i| SpecifiedUrl::parse(context, i)) { return Ok(ShapeSource::ImageOrUrl(url)); } @@ -89,7 +89,7 @@ impl Parse for FloatAreaShape { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(image) = input.try(|i| Image::parse_with_cors_anonymous(context, i)) { + if let Ok(image) = input.r#try(|i| Image::parse_with_cors_anonymous(context, i)) { return Ok(ShapeSource::ImageOrUrl(image)); } @@ -106,7 +106,7 @@ where context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(ShapeSource::None); } @@ -119,7 +119,7 @@ where return false; // already parsed this component } - *component = input.try(|i| U::parse(context, i)).ok(); + *component = input.r#try(|i| U::parse(context, i)).ok(); component.is_some() } @@ -147,7 +147,7 @@ impl Parse for GeometryBox { _context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(shape_box) = input.try(|i| ShapeBox::parse(i)) { + if let Ok(shape_box) = input.r#try(|i| ShapeBox::parse(i)) { return Ok(GeometryBox::ShapeBox(shape_box)); } @@ -197,7 +197,7 @@ impl InsetRect { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let rect = Rect::parse_with(context, input, LengthOrPercentage::parse)?; - let round = if input.try(|i| i.expect_ident_matching("round")).is_ok() { + let round = if input.r#try(|i| i.expect_ident_matching("round")).is_ok() { Some(BorderRadius::parse(context, input)?) } else { None @@ -225,9 +225,9 @@ impl Circle { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let radius = input - .try(|i| ShapeRadius::parse(context, i)) + .r#try(|i| ShapeRadius::parse(context, i)) .unwrap_or_default(); - let position = if input.try(|i| i.expect_ident_matching("at")).is_ok() { + let position = if input.r#try(|i| i.expect_ident_matching("at")).is_ok() { Position::parse(context, input)? } else { Position::center() @@ -270,14 +270,14 @@ impl Ellipse { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let (a, b) = input - .try(|i| -> Result<_, ParseError> { + .r#try(|i| -> Result<_, ParseError> { Ok(( ShapeRadius::parse(context, i)?, ShapeRadius::parse(context, i)?, )) }) .unwrap_or_default(); - let position = if input.try(|i| i.expect_ident_matching("at")).is_ok() { + let position = if input.r#try(|i| i.expect_ident_matching("at")).is_ok() { Position::parse(context, input)? } else { Position::center() @@ -315,7 +315,7 @@ impl Parse for ShapeRadius { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) { + if let Ok(lop) = input.r#try(|i| LengthOrPercentage::parse_non_negative(context, i)) { return Ok(generic::ShapeRadius::Length(lop)); } @@ -419,7 +419,7 @@ impl Polygon { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let fill = input - .try(|i| -> Result<_, ParseError> { + .r#try(|i| -> Result<_, ParseError> { let fill = FillRule::parse(i)?; i.expect_comma()?; // only eat the comma if there is something before it Ok(fill) @@ -457,7 +457,7 @@ impl Path { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let fill = input - .try(|i| -> Result<_, ParseError> { + .r#try(|i| -> Result<_, ParseError> { let fill = FillRule::parse(i)?; i.expect_comma()?; Ok(fill) diff --git a/components/style/values/specified/border.rs b/components/style/values/specified/border.rs index 27f403c4a28..27b9355c21d 100644 --- a/components/style/values/specified/border.rs +++ b/components/style/values/specified/border.rs @@ -4,20 +4,20 @@ //! Specified types for CSS values related to borders. +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::{self, Context, ToComputedValue}; +use crate::values::generics::border::BorderCornerRadius as GenericBorderCornerRadius; +use crate::values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth; +use crate::values::generics::border::BorderImageSlice as GenericBorderImageSlice; +use crate::values::generics::border::BorderRadius as GenericBorderRadius; +use crate::values::generics::border::BorderSpacing as GenericBorderSpacing; +use crate::values::generics::rect::Rect; +use crate::values::generics::size::Size; +use crate::values::specified::length::{Length, LengthOrPercentage, NonNegativeLength}; +use crate::values::specified::{AllowQuirks, Number, NumberOrPercentage}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, ToCss}; -use values::computed::{self, Context, ToComputedValue}; -use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius; -use values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth; -use values::generics::border::BorderImageSlice as GenericBorderImageSlice; -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::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)] @@ -58,7 +58,7 @@ impl BorderSideWidth { allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { if let Ok(length) = - input.try(|i| Length::parse_non_negative_quirky(context, i, allow_quirks)) + input.r#try(|i| Length::parse_non_negative_quirky(context, i, allow_quirks)) { return Ok(BorderSideWidth::Length(length)); } @@ -115,11 +115,11 @@ impl Parse for BorderImageSideWidth { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("auto")).is_ok() { return Ok(GenericBorderImageSideWidth::Auto); } - if let Ok(len) = input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) { + if let Ok(len) = input.r#try(|i| LengthOrPercentage::parse_non_negative(context, i)) { return Ok(GenericBorderImageSideWidth::Length(len)); } @@ -133,10 +133,10 @@ impl Parse for BorderImageSlice { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - let mut fill = input.try(|i| i.expect_ident_matching("fill")).is_ok(); + let mut fill = input.r#try(|i| i.expect_ident_matching("fill")).is_ok(); let offsets = Rect::parse_with(context, input, NumberOrPercentage::parse_non_negative)?; if !fill { - fill = input.try(|i| i.expect_ident_matching("fill")).is_ok(); + fill = input.r#try(|i| i.expect_ident_matching("fill")).is_ok(); } Ok(GenericBorderImageSlice { offsets: offsets, @@ -151,7 +151,7 @@ impl Parse for BorderRadius { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let widths = Rect::parse_with(context, input, LengthOrPercentage::parse_non_negative)?; - let heights = if input.try(|i| i.expect_delim('/')).is_ok() { + let heights = if input.r#try(|i| i.expect_delim('/')).is_ok() { Rect::parse_with(context, input, LengthOrPercentage::parse_non_negative)? } else { widths.clone() @@ -236,7 +236,7 @@ impl Parse for BorderImageRepeat { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let horizontal = BorderImageRepeatKeyword::parse(input)?; - let vertical = input.try(BorderImageRepeatKeyword::parse).ok(); + let vertical = input.r#try(BorderImageRepeatKeyword::parse).ok(); Ok(BorderImageRepeat( horizontal, vertical.unwrap_or(horizontal), diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 060cb093d8e..4e7adb935dd 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -4,24 +4,26 @@ //! Specified types for box properties. +use crate::custom_properties::Name as CustomPropertyName; +use crate::parser::{Parse, ParserContext}; +use crate::properties::{ + LonghandId, PropertyDeclarationId, PropertyFlags, PropertyId, ShorthandId, +}; +use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; +use crate::values::generics::box_::Perspective as GenericPerspective; +use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign; +use crate::values::specified::length::{LengthOrPercentage, NonNegativeLength}; +use crate::values::specified::{AllowQuirks, Number}; +use crate::values::{CustomIdent, KeyframesName}; +use crate::Atom; use cssparser::Parser; -use custom_properties::Name as CustomPropertyName; -use parser::{Parse, ParserContext}; -use properties::{LonghandId, PropertyDeclarationId, PropertyFlags, PropertyId, ShorthandId}; use selectors::parser::SelectorParseErrorKind; use std::fmt::{self, Write}; use style_traits::{CssWriter, KeywordsCollectFn, ParseError}; use style_traits::{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::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; + use crate::stylesheets::Origin; context.stylesheet_origin == Origin::UserAgent || context.chrome_rules_enabled() } @@ -308,7 +310,7 @@ impl Parse for VerticalAlign { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if let Ok(lop) = - input.try(|i| LengthOrPercentage::parse_quirky(context, i, AllowQuirks::Yes)) + input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, AllowQuirks::Yes)) { return Ok(GenericVerticalAlign::Length(lop)); } @@ -339,7 +341,7 @@ impl Parse for AnimationIterationCount { input: &mut ::cssparser::Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("infinite")) + .r#try(|input| input.expect_ident_matching("infinite")) .is_ok() { return Ok(GenericAnimationIterationCount::Infinite); @@ -392,7 +394,7 @@ impl Parse for AnimationName { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(name) = input.try(|input| KeyframesName::parse(context, input)) { + if let Ok(name) = input.r#try(|input| KeyframesName::parse(context, input)) { return Ok(AnimationName(Some(name))); } @@ -555,7 +557,7 @@ impl Parse for WillChange { input: &mut Parser<'i, 't>, ) -> Result<WillChange, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("auto")) + .r#try(|input| input.expect_ident_matching("auto")) .is_ok() { return Ok(WillChange::Auto); @@ -644,14 +646,14 @@ impl Parse for TouchAction { "none" => Ok(TouchAction::TOUCH_ACTION_NONE), "manipulation" => Ok(TouchAction::TOUCH_ACTION_MANIPULATION), "pan-x" => { - if input.try(|i| i.expect_ident_matching("pan-y")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("pan-y")).is_ok() { Ok(TouchAction::TOUCH_ACTION_PAN_X | TouchAction::TOUCH_ACTION_PAN_Y) } else { Ok(TouchAction::TOUCH_ACTION_PAN_X) } }, "pan-y" => { - if input.try(|i| i.expect_ident_matching("pan-x")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("pan-x")).is_ok() { Ok(TouchAction::TOUCH_ACTION_PAN_X | TouchAction::TOUCH_ACTION_PAN_Y) } else { Ok(TouchAction::TOUCH_ACTION_PAN_Y) @@ -755,7 +757,7 @@ impl Parse for Contain { input: &mut Parser<'i, 't>, ) -> Result<Contain, ParseError<'i>> { let mut result = Contain::empty(); - while let Ok(name) = input.try(|i| i.expect_ident_cloned()) { + while let Ok(name) = input.r#try(|i| i.expect_ident_cloned()) { let flag = match_ignore_ascii_case! { &name, "size" => Some(Contain::SIZE), "layout" => Some(Contain::LAYOUT), @@ -792,7 +794,7 @@ impl Parse for Perspective { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(GenericPerspective::None); } Ok(GenericPerspective::Length(NonNegativeLength::parse( @@ -821,7 +823,7 @@ impl ToCss for TransitionProperty { where W: Write, { - use values::serialize_atom_name; + use crate::values::serialize_atom_name; match *self { TransitionProperty::Shorthand(ref s) => s.to_css(dest), TransitionProperty::Longhand(ref l) => l.to_css(dest), diff --git a/components/style/values/specified/calc.rs b/components/style/values/specified/calc.rs index 6a0f54b3926..1b589ebc89c 100644 --- a/components/style/values/specified/calc.rs +++ b/components/style/values/specified/calc.rs @@ -6,16 +6,16 @@ //! //! [calc]: https://drafts.csswg.org/css-values/#calc-notation +use crate::parser::ParserContext; +use crate::values::computed; +use crate::values::specified::length::ViewportPercentageLength; +use crate::values::specified::length::{AbsoluteLength, FontRelativeLength, NoCalcLength}; +use crate::values::specified::{Angle, Time}; +use crate::values::{CSSFloat, CSSInteger}; use cssparser::{AngleOrNumber, NumberOrPercentage, Parser, Token}; -use parser::ParserContext; use std::fmt::{self, Write}; use style_traits::values::specified::AllowedNumericType; use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; -use values::computed; -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)] diff --git a/components/style/values/specified/color.rs b/components/style/values/specified/color.rs index cc9884525ff..47f337ab40d 100644 --- a/components/style/values/specified/color.rs +++ b/components/style/values/specified/color.rs @@ -5,21 +5,21 @@ //! Specified color values. use super::AllowQuirks; +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::{Color as ComputedColor, Context, ToComputedValue}; +use crate::values::generics::color::Color as GenericColor; +use crate::values::specified::calc::CalcNode; use cssparser::{AngleOrNumber, Color as CSSParserColor, Parser, Token, RGBA}; use cssparser::{BasicParseErrorKind, NumberOrPercentage, ParseErrorKind}; #[cfg(feature = "gecko")] use gecko_bindings::structs::nscolor; use itoa; -use parser::{Parse, ParserContext}; #[cfg(feature = "gecko")] use properties::longhands::system_colors::SystemColor; 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 values::computed::{Color as ComputedColor, Context, ToComputedValue}; -use values::generics::color::Color as GenericColor; -use values::specified::calc::CalcNode; /// Specified color value #[derive(Clone, Debug, MallocSizeOf, PartialEq)] @@ -73,7 +73,7 @@ impl<'a, 'b: 'a, 'i: 'a> ::cssparser::ColorComponentParser<'i> for ColorComponen &self, input: &mut Parser<'i, 't>, ) -> Result<AngleOrNumber, ParseError<'i>> { - use values::specified::Angle; + use crate::values::specified::Angle; let location = input.current_source_location(); let token = input.next()?.clone(); @@ -99,13 +99,13 @@ impl<'a, 'b: 'a, 'i: 'a> ::cssparser::ColorComponentParser<'i> for ColorComponen } fn parse_percentage<'t>(&self, input: &mut Parser<'i, 't>) -> Result<f32, ParseError<'i>> { - use values::specified::Percentage; + use crate::values::specified::Percentage; Ok(Percentage::parse(self.0, input)?.get()) } fn parse_number<'t>(&self, input: &mut Parser<'i, 't>) -> Result<f32, ParseError<'i>> { - use values::specified::Number; + use crate::values::specified::Number; Ok(Number::parse(self.0, input)?.get()) } @@ -142,7 +142,7 @@ impl Parse for Color { input.reset(&start); let compontent_parser = ColorComponentParser(&*context); - match input.try(|i| CSSParserColor::parse_with(&compontent_parser, i)) { + match input.r#try(|i| CSSParserColor::parse_with(&compontent_parser, i)) { Ok(value) => Ok(match value { CSSParserColor::CurrentColor => Color::CurrentColor, CSSParserColor::RGBA(rgba) => Color::Numeric { @@ -245,7 +245,7 @@ impl Color { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - input.try(|i| Self::parse(context, i)).or_else(|e| { + input.r#try(|i| Self::parse(context, i)).or_else(|e| { if !allow_quirks.allowed(context.quirks_mode) { return Err(e); } diff --git a/components/style/values/specified/column.rs b/components/style/values/specified/column.rs index 4cd8ad0777f..2b6a919b232 100644 --- a/components/style/values/specified/column.rs +++ b/components/style/values/specified/column.rs @@ -4,11 +4,11 @@ //! Specified types for the column properties. +use crate::parser::{Parse, ParserContext}; +use crate::values::generics::column::ColumnCount as GenericColumnCount; +use crate::values::specified::PositiveInteger; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::ParseError; -use values::generics::column::ColumnCount as GenericColumnCount; -use values::specified::PositiveInteger; /// A specified type for `column-count` values. pub type ColumnCount = GenericColumnCount<PositiveInteger>; @@ -18,7 +18,7 @@ impl Parse for ColumnCount { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("auto")).is_ok() { return Ok(GenericColumnCount::Auto); } Ok(GenericColumnCount::Integer(PositiveInteger::parse( diff --git a/components/style/values/specified/counters.rs b/components/style/values/specified/counters.rs index d994339c5b5..0a59720a03a 100644 --- a/components/style/values/specified/counters.rs +++ b/components/style/values/specified/counters.rs @@ -5,22 +5,22 @@ //! Specified types for counter properties. #[cfg(feature = "servo")] -use computed_values::list_style_type::T as ListStyleType; +use crate::computed_values::list_style_type::T as ListStyleType; +use crate::parser::{Parse, ParserContext}; +use crate::values::generics::counters as generics; +use crate::values::generics::counters::CounterIncrement as GenericCounterIncrement; +use crate::values::generics::counters::CounterPair; +use crate::values::generics::counters::CounterReset as GenericCounterReset; +use crate::values::specified::url::SpecifiedImageUrl; +use crate::values::specified::Integer; +use crate::values::CustomIdent; use cssparser::{Parser, Token}; -use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use style_traits::{ParseError, StyleParseErrorKind}; -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::CustomIdent; /// A specified value for the `counter-increment` property. pub type CounterIncrement = GenericCounterIncrement<Integer>; @@ -52,7 +52,7 @@ fn parse_counters<'i, 't>( default_value: i32, ) -> Result<Vec<CounterPair<Integer>>, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(vec![]); @@ -68,7 +68,7 @@ fn parse_counters<'i, 't>( }; let value = input - .try(|input| Integer::parse(context, input)) + .r#try(|input| Integer::parse(context, input)) .unwrap_or(Integer::new(default_value)); counters.push(CounterPair { name, value }); } @@ -90,7 +90,7 @@ impl Content { #[cfg(feature = "servo")] fn parse_counter_style(_: &ParserContext, input: &mut Parser) -> ListStyleType { input - .try(|input| { + .r#try(|input| { input.expect_comma()?; ListStyleType::parse(input) }) @@ -100,7 +100,7 @@ impl Content { #[cfg(feature = "gecko")] fn parse_counter_style(context: &ParserContext, input: &mut Parser) -> CounterStyleOrNone { input - .try(|input| { + .r#try(|input| { input.expect_comma()?; CounterStyleOrNone::parse(context, input) }) @@ -117,13 +117,13 @@ impl Parse for Content { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("normal")) + .r#try(|input| input.expect_ident_matching("normal")) .is_ok() { return Ok(generics::Content::Normal); } if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(generics::Content::None); @@ -131,7 +131,7 @@ impl Parse for Content { #[cfg(feature = "gecko")] { if input - .try(|input| input.expect_ident_matching("-moz-alt-content")) + .r#try(|input| input.expect_ident_matching("-moz-alt-content")) .is_ok() { return Ok(generics::Content::MozAltContent); @@ -142,7 +142,7 @@ impl Parse for Content { loop { #[cfg(feature = "gecko")] { - if let Ok(url) = input.try(|i| SpecifiedImageUrl::parse(context, i)) { + if let Ok(url) = input.r#try(|i| SpecifiedImageUrl::parse(context, i)) { content.push(generics::ContentItem::Url(url)); continue; } diff --git a/components/style/values/specified/easing.rs b/components/style/values/specified/easing.rs index ab3b4cb43bc..d65f1897d4c 100644 --- a/components/style/values/specified/easing.rs +++ b/components/style/values/specified/easing.rs @@ -4,14 +4,14 @@ //! Specified types for CSS Easing functions. +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::easing::TimingFunction as ComputedTimingFunction; +use crate::values::generics::easing::TimingFunction as GenericTimingFunction; +use crate::values::generics::easing::{StepPosition, TimingKeyword}; +use crate::values::specified::{Integer, Number}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use style_traits::{ParseError, StyleParseErrorKind}; -use values::computed::easing::TimingFunction as ComputedTimingFunction; -use values::generics::easing::TimingFunction as GenericTimingFunction; -use values::generics::easing::{StepPosition, TimingKeyword}; -use values::specified::{Integer, Number}; /// A specified timing function. pub type TimingFunction = GenericTimingFunction<Integer, Number>; @@ -21,10 +21,10 @@ impl Parse for TimingFunction { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(keyword) = input.try(TimingKeyword::parse) { + if let Ok(keyword) = input.r#try(TimingKeyword::parse) { return Ok(GenericTimingFunction::Keyword(keyword)); } - if let Ok(ident) = input.try(|i| i.expect_ident_cloned()) { + if let Ok(ident) = input.r#try(|i| i.expect_ident_cloned()) { let position = match_ignore_ascii_case! { &ident, "step-start" => StepPosition::Start, "step-end" => StepPosition::End, @@ -57,7 +57,7 @@ impl Parse for TimingFunction { }, "steps" => { let steps = Integer::parse_positive(context, i)?; - let position = i.try(|i| { + let position = i.r#try(|i| { i.expect_comma()?; StepPosition::parse(context, i) }).unwrap_or(StepPosition::End); diff --git a/components/style/values/specified/effects.rs b/components/style/values/specified/effects.rs index 3562d4fdfa4..0dc41d4fda6 100644 --- a/components/style/values/specified/effects.rs +++ b/components/style/values/specified/effects.rs @@ -4,23 +4,25 @@ //! Specified types for CSS values related to effects. +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::effects::BoxShadow as ComputedBoxShadow; +use crate::values::computed::effects::SimpleShadow as ComputedSimpleShadow; +use crate::values::computed::{ + Context, NonNegativeNumber as ComputedNonNegativeNumber, ToComputedValue, +}; +use crate::values::generics::effects::BoxShadow as GenericBoxShadow; +use crate::values::generics::effects::Filter as GenericFilter; +use crate::values::generics::effects::SimpleShadow as GenericSimpleShadow; +use crate::values::generics::NonNegative; +use crate::values::specified::color::Color; +use crate::values::specified::length::{Length, NonNegativeLength}; +use crate::values::specified::{Angle, NumberOrPercentage}; +#[cfg(not(feature = "gecko"))] +use crate::values::Impossible; use cssparser::{self, BasicParseErrorKind, Parser, Token}; -use parser::{Parse, ParserContext}; use style_traits::{ParseError, StyleParseErrorKind, ValueParseErrorKind}; -use values::computed::effects::BoxShadow as ComputedBoxShadow; -use values::computed::effects::SimpleShadow as ComputedSimpleShadow; -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::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 = @@ -77,7 +79,7 @@ impl ToComputedValue for Factor { #[inline] fn to_computed_value(&self, context: &Context) -> Self::ComputedValue { - use values::computed::NumberOrPercentage; + use crate::values::computed::NumberOrPercentage; match self.0.to_computed_value(context) { NumberOrPercentage::Number(n) => n.into(), NumberOrPercentage::Percentage(p) => p.0.into(), @@ -107,7 +109,7 @@ impl Parse for BoxShadow { loop { if !inset { if input - .try(|input| input.expect_ident_matching("inset")) + .r#try(|input| input.expect_ident_matching("inset")) .is_ok() { inset = true; @@ -115,14 +117,14 @@ impl Parse for BoxShadow { } } if lengths.is_none() { - let value = input.try::<_, _, ParseError>(|i| { + let value = input.r#try::<_, _, ParseError>(|i| { let horizontal = Length::parse(context, i)?; let vertical = Length::parse(context, i)?; let (blur, spread) = match i - .try::<_, _, ParseError>(|i| Length::parse_non_negative(context, i)) + .r#try::<_, _, ParseError>(|i| Length::parse_non_negative(context, i)) { Ok(blur) => { - let spread = i.try(|i| Length::parse(context, i)).ok(); + let spread = i.r#try(|i| Length::parse(context, i)).ok(); (Some(blur.into()), spread) }, Err(_) => (None, None), @@ -135,7 +137,7 @@ impl Parse for BoxShadow { } } if color.is_none() { - if let Ok(value) = input.try(|i| Color::parse(context, i)) { + if let Ok(value) = input.r#try(|i| Color::parse(context, i)) { color = Some(value); continue; } @@ -192,7 +194,7 @@ impl Parse for Filter { ) -> Result<Self, ParseError<'i>> { #[cfg(feature = "gecko")] { - if let Ok(url) = input.try(|i| SpecifiedUrl::parse(context, i)) { + if let Ok(url) = input.r#try(|i| SpecifiedUrl::parse(context, i)) { return Ok(GenericFilter::Url(url)); } } @@ -251,12 +253,12 @@ impl Parse for SimpleShadow { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - let color = input.try(|i| Color::parse(context, i)).ok(); + let color = input.r#try(|i| Color::parse(context, i)).ok(); let horizontal = Length::parse(context, input)?; let vertical = Length::parse(context, input)?; - let blur = input.try(|i| Length::parse_non_negative(context, i)).ok(); + let blur = input.r#try(|i| Length::parse_non_negative(context, i)).ok(); let blur = blur.map(NonNegative::<Length>); - let color = color.or_else(|| input.try(|i| Color::parse(context, i)).ok()); + let color = color.or_else(|| input.r#try(|i| Color::parse(context, i)).ok()); Ok(SimpleShadow { color, diff --git a/components/style/values/specified/flex.rs b/components/style/values/specified/flex.rs index f82438036ba..eb163437ba5 100644 --- a/components/style/values/specified/flex.rs +++ b/components/style/values/specified/flex.rs @@ -4,14 +4,14 @@ //! Specified types for CSS values related to flexbox. +use crate::parser::{Parse, ParserContext}; +use crate::values::generics::flex::FlexBasis as GenericFlexBasis; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::ParseError; -use values::generics::flex::FlexBasis as GenericFlexBasis; /// The `width` value type. #[cfg(feature = "servo")] -pub type Width = ::values::specified::NonNegativeLengthOrPercentageOrAuto; +pub type Width = crate::values::specified::NonNegativeLengthOrPercentageOrAuto; /// The `width` value type. #[cfg(feature = "gecko")] @@ -25,7 +25,7 @@ impl Parse for FlexBasis { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(width) = input.try(|i| Width::parse(context, i)) { + if let Ok(width) = input.r#try(|i| Width::parse(context, i)) { return Ok(GenericFlexBasis::Width(width)); } try_match_ident_ignore_ascii_case! { input, diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index 45c9aa0e4e6..4c5b3c5c8d6 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -6,28 +6,31 @@ use app_units::Au; use byteorder::{BigEndian, ByteOrder}; +use crate::parser::{Parse, ParserContext}; +use crate::properties::longhands::system_font::SystemFont; +use crate::values::computed::font::{FamilyName, FontFamilyList, FontStyleAngle, SingleFontFamily}; +use crate::values::computed::{ + font as computed, Context, Length, NonNegativeLength, ToComputedValue, +}; +use crate::values::computed::{Angle as ComputedAngle, Percentage as ComputedPercentage}; +use crate::values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag}; +use crate::values::generics::font::{KeywordSize, VariationValue}; +use crate::values::generics::NonNegative; +use crate::values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX}; +use crate::values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage}; +use crate::values::specified::{NoCalcLength, Number, Percentage}; +use crate::values::CustomIdent; +use crate::Atom; use cssparser::{Parser, Token}; #[cfg(feature = "gecko")] use gecko_bindings::bindings; #[cfg(feature = "gecko")] 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 values::computed::font::{FamilyName, FontFamilyList, FontStyleAngle, SingleFontFamily}; -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::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}; -use values::specified::{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 { @@ -115,7 +118,7 @@ impl Parse for FontWeight { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<FontWeight, ParseError<'i>> { - if let Ok(absolute) = input.try(|input| AbsoluteFontWeight::parse(context, input)) { + if let Ok(absolute) = input.r#try(|input| AbsoluteFontWeight::parse(context, input)) { return Ok(FontWeight::Absolute(absolute)); } @@ -188,7 +191,7 @@ impl Parse for AbsoluteFontWeight { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(number) = input.try(|input| Number::parse(context, input)) { + if let Ok(number) = input.r#try(|input| Number::parse(context, input)) { // We could add another AllowedNumericType value, but it doesn't // seem worth it just for a single property with such a weird range, // so we do the clamping here manually. @@ -240,7 +243,7 @@ impl Parse for SpecifiedFontStyle { "normal" => generics::FontStyle::Normal, "italic" => generics::FontStyle::Italic, "oblique" => { - let angle = input.try(|input| Self::parse_angle(context, input)) + let angle = input.r#try(|input| Self::parse_angle(context, input)) .unwrap_or_else(|_| Self::default_angle()); generics::FontStyle::Oblique(angle) @@ -479,7 +482,8 @@ impl Parse for FontStretch { // // Values less than 0% are not allowed and are treated as parse // errors. - if let Ok(percentage) = input.try(|input| Percentage::parse_non_negative(context, input)) { + if let Ok(percentage) = input.r#try(|input| Percentage::parse_non_negative(context, input)) + { return Ok(FontStretch::Stretch(percentage)); } @@ -679,7 +683,7 @@ impl Parse for FontSizeAdjust { input: &mut Parser<'i, 't>, ) -> Result<FontSizeAdjust, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(FontSizeAdjust::None); @@ -850,7 +854,7 @@ impl FontSize { context: &Context, base_size: FontBaseSize, ) -> computed::FontSize { - use values::specified::length::FontRelativeLength; + use crate::values::specified::length::FontRelativeLength; let compose_keyword = |factor| { context @@ -987,12 +991,12 @@ impl FontSize { allow_quirks: AllowQuirks, ) -> Result<FontSize, ParseError<'i>> { if let Ok(lop) = - input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) + input.r#try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) { return Ok(FontSize::Length(lop)); } - if let Ok(kw) = input.try(KeywordSize::parse) { + if let Ok(kw) = input.r#try(KeywordSize::parse) { return Ok(FontSize::Keyword(kw.into())); } @@ -1174,7 +1178,7 @@ impl Parse for FontVariantAlternates { ) -> Result<FontVariantAlternates, ParseError<'i>> { let mut alternates = Vec::new(); if input - .try(|input| input.expect_ident_matching("normal")) + .r#try(|input| input.expect_ident_matching("normal")) .is_ok() { return Ok(FontVariantAlternates::Value(VariantAlternatesList( @@ -1191,7 +1195,7 @@ impl Parse for FontVariantAlternates { parsed_alternates |= $flag; ) ); - while let Ok(_) = input.try(|input| { + while let Ok(_) = input.r#try(|input| { // FIXME: remove clone() when lifetimes are non-lexical match input.next()?.clone() { Token::Ident(ref value) if value.eq_ignore_ascii_case("historical-forms") => { @@ -1406,13 +1410,13 @@ impl Parse for FontVariantEastAsian { let mut result = VariantEastAsian::empty(); if input - .try(|input| input.expect_ident_matching("normal")) + .r#try(|input| input.expect_ident_matching("normal")) .is_ok() { return Ok(FontVariantEastAsian::Value(result)); } - while let Ok(flag) = input.try(|input| { + while let Ok(flag) = input.r#try(|input| { Ok( match_ignore_ascii_case! { &input.expect_ident().map_err(|_| ())?, "jis78" => @@ -1630,19 +1634,19 @@ impl Parse for FontVariantLigatures { let mut result = VariantLigatures::empty(); if input - .try(|input| input.expect_ident_matching("normal")) + .r#try(|input| input.expect_ident_matching("normal")) .is_ok() { return Ok(FontVariantLigatures::Value(result)); } if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(FontVariantLigatures::Value(VariantLigatures::NONE)); } - while let Ok(flag) = input.try(|input| { + while let Ok(flag) = input.r#try(|input| { Ok( match_ignore_ascii_case! { &input.expect_ident().map_err(|_| ())?, "common-ligatures" => @@ -1839,13 +1843,13 @@ impl Parse for FontVariantNumeric { let mut result = VariantNumeric::empty(); if input - .try(|input| input.expect_ident_matching("normal")) + .r#try(|input| input.expect_ident_matching("normal")) .is_ok() { return Ok(FontVariantNumeric::Value(result)); } - while let Ok(flag) = input.try(|input| { + while let Ok(flag) = input.r#try(|input| { Ok( match_ignore_ascii_case! { &input.expect_ident().map_err(|_| ())?, "ordinal" => @@ -1979,14 +1983,14 @@ impl Parse for FontSynthesis { "none" => Ok(result), "weight" => { result.weight = true; - if input.try(|input| input.expect_ident_matching("style")).is_ok() { + if input.r#try(|input| input.expect_ident_matching("style")).is_ok() { result.style = true; } Ok(result) }, "style" => { result.style = true; - if input.try(|input| input.expect_ident_matching("weight")).is_ok() { + if input.r#try(|input| input.expect_ident_matching("weight")).is_ok() { result.weight = true; } Ok(result) @@ -2125,7 +2129,7 @@ impl Parse for FontLanguageOverride { input: &mut Parser<'i, 't>, ) -> Result<FontLanguageOverride, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("normal")) + .r#try(|input| input.expect_ident_matching("normal")) .is_ok() { return Ok(FontLanguageOverride::Normal); @@ -2192,7 +2196,7 @@ fn parse_one_feature_value<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Integer, ParseError<'i>> { - if let Ok(integer) = input.try(|i| Integer::parse_non_negative(context, i)) { + if let Ok(integer) = input.r#try(|i| Integer::parse_non_negative(context, i)) { return Ok(integer); } @@ -2210,7 +2214,7 @@ impl Parse for FeatureTagValue<Integer> { ) -> Result<Self, ParseError<'i>> { let tag = FontTag::parse(context, input)?; let value = input - .try(|i| parse_one_feature_value(context, i)) + .r#try(|i| parse_one_feature_value(context, i)) .unwrap_or_else(|_| Integer::new(1)); Ok(Self { tag, value }) @@ -2328,7 +2332,7 @@ impl Parse for MozScriptLevel { input: &mut Parser<'i, 't>, ) -> Result<MozScriptLevel, ParseError<'i>> { // We don't bother to handle calc here. - if let Ok(i) = input.try(|i| i.expect_integer()) { + if let Ok(i) = input.r#try(|i| i.expect_integer()) { return Ok(MozScriptLevel::Relative(i)); } input.expect_ident_matching("auto")?; diff --git a/components/style/values/specified/grid.rs b/components/style/values/specified/grid.rs index 80b98688979..e835a8d86b1 100644 --- a/components/style/values/specified/grid.rs +++ b/components/style/values/specified/grid.rs @@ -5,16 +5,16 @@ //! CSS handling for the computed value of //! [grids](https://drafts.csswg.org/css-grid/) +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::{self, Context, ToComputedValue}; +use crate::values::generics::grid::{GridTemplateComponent, RepeatCount, TrackBreadth}; +use crate::values::generics::grid::{LineNameList, TrackKeyword, TrackRepeat, TrackSize}; +use crate::values::generics::grid::{TrackList, TrackListType, TrackListValue}; +use crate::values::specified::{Integer, LengthOrPercentage}; +use crate::values::{CSSFloat, CustomIdent}; use cssparser::{ParseError as CssParseError, Parser, Token}; -use parser::{Parse, ParserContext}; use std::mem; use style_traits::{ParseError, StyleParseErrorKind}; -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<CSSFloat, ParseError<'i>> { @@ -36,11 +36,11 @@ impl Parse for TrackBreadth<LengthOrPercentage> { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) { + if let Ok(lop) = input.r#try(|i| LengthOrPercentage::parse_non_negative(context, i)) { return Ok(TrackBreadth::Breadth(lop)); } - if let Ok(f) = input.try(parse_flex) { + if let Ok(f) = input.r#try(parse_flex) { return Ok(TrackBreadth::Fr(f)); } @@ -53,14 +53,17 @@ impl Parse for TrackSize<LengthOrPercentage> { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(b) = input.try(|i| TrackBreadth::parse(context, i)) { + if let Ok(b) = input.r#try(|i| TrackBreadth::parse(context, i)) { return Ok(TrackSize::Breadth(b)); } - if input.try(|i| i.expect_function_matching("minmax")).is_ok() { + if input + .r#try(|i| i.expect_function_matching("minmax")) + .is_ok() + { return input.parse_nested_block(|input| { let inflexible_breadth = - match input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) { + match input.r#try(|i| LengthOrPercentage::parse_non_negative(context, i)) { Ok(lop) => TrackBreadth::Breadth(lop), Err(..) => { let keyword = TrackKeyword::parse(input)?; @@ -92,7 +95,7 @@ pub fn parse_line_names<'i, 't>( input.expect_square_bracket_block()?; input.parse_nested_block(|input| { let mut values = vec![]; - while let Ok((loc, ident)) = input.try(|i| -> Result<_, CssParseError<()>> { + while let Ok((loc, ident)) = input.r#try(|i| -> Result<_, CssParseError<()>> { Ok((i.current_source_location(), i.expect_ident_cloned()?)) }) { let ident = CustomIdent::from_ident(loc, &ident, &["span", "auto"])?; @@ -123,7 +126,7 @@ impl TrackRepeat<LengthOrPercentage, Integer> { input: &mut Parser<'i, 't>, ) -> Result<(Self, RepeatType), ParseError<'i>> { input - .try(|i| i.expect_function_matching("repeat").map_err(|e| e.into())) + .r#try(|i| i.expect_function_matching("repeat").map_err(|e| e.into())) .and_then(|_| { input.parse_nested_block(|input| { let count = RepeatCount::parse(context, input)?; @@ -143,9 +146,9 @@ impl TrackRepeat<LengthOrPercentage, Integer> { loop { current_names = input - .try(parse_line_names) + .r#try(parse_line_names) .unwrap_or(vec![].into_boxed_slice()); - if let Ok(track_size) = input.try(|i| TrackSize::parse(context, i)) { + if let Ok(track_size) = input.r#try(|i| TrackSize::parse(context, i)) { if !track_size.is_fixed() { if is_auto { // should be <fixed-size> for <auto-repeat> @@ -169,7 +172,7 @@ impl TrackRepeat<LengthOrPercentage, Integer> { // gecko implements new spec. names.push( input - .try(parse_line_names) + .r#try(parse_line_names) .unwrap_or(vec![].into_boxed_slice()), ); break; @@ -223,10 +226,10 @@ impl Parse for TrackList<LengthOrPercentage, Integer> { loop { current_names.extend_from_slice( &mut input - .try(parse_line_names) + .r#try(parse_line_names) .unwrap_or(vec![].into_boxed_slice()), ); - if let Ok(track_size) = input.try(|i| TrackSize::parse(context, i)) { + if let Ok(track_size) = input.r#try(|i| TrackSize::parse(context, i)) { if !track_size.is_fixed() { atleast_one_not_fixed = true; if auto_repeat.is_some() { @@ -239,7 +242,7 @@ impl Parse for TrackList<LengthOrPercentage, Integer> { names.push(vec.into_boxed_slice()); values.push(TrackListValue::TrackSize(track_size)); } else if let Ok((repeat, type_)) = - input.try(|i| TrackRepeat::parse_with_repeat_type(context, i)) + input.r#try(|i| TrackRepeat::parse_with_repeat_type(context, i)) { if list_type == TrackListType::Explicit { list_type = TrackListType::Normal; // <explicit-track-list> doesn't contain repeat() @@ -401,7 +404,7 @@ impl Parse for GridTemplateComponent<LengthOrPercentage, Integer> { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(GridTemplateComponent::None); } @@ -416,7 +419,7 @@ impl GridTemplateComponent<LengthOrPercentage, Integer> { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if allow_grid_template_subgrids() { - if let Ok(t) = input.try(|i| LineNameList::parse(context, i)) { + if let Ok(t) = input.r#try(|i| LineNameList::parse(context, i)) { return Ok(GridTemplateComponent::Subgrid(t)); } } diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index e515082d860..18b0b6b3053 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -7,9 +7,18 @@ //! //! [image]: https://drafts.csswg.org/css-images/#image-values +use crate::custom_properties::SpecifiedValue; +use crate::parser::{Parse, ParserContext}; +use crate::values::generics::image::PaintWorklet; +use crate::values::generics::image::{self as generic, Circle, CompatMode, Ellipse, ShapeExtent}; +use crate::values::generics::position::Position as GenericPosition; +use crate::values::specified::position::{LegacyPosition, Position, PositionComponent, Side, X, Y}; +use crate::values::specified::url::SpecifiedImageUrl; +use crate::values::specified::{Angle, Color, Length, LengthOrPercentage}; +use crate::values::specified::{Number, NumberOrPercentage, Percentage}; +use crate::values::{Either, None_}; +use crate::Atom; use cssparser::{Delimiter, Parser, Token}; -use custom_properties::SpecifiedValue; -use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; #[cfg(feature = "servo")] use servo_url::ServoUrl; @@ -19,15 +28,6 @@ use style_traits::{CssType, CssWriter, KeywordsCollectFn, ParseError}; use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss}; #[cfg(feature = "gecko")] use values::computed::{Context, Position as ComputedPosition, ToComputedValue}; -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::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<None_, Image>; @@ -39,7 +39,7 @@ impl ImageLayer { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(v) = input.try(|i| None_::parse(context, i)) { + if let Ok(v) = input.r#try(|i| None_::parse(context, i)) { return Ok(Either::First(v)); } Image::parse_with_cors_anonymous(context, input).map(Either::Second) @@ -142,19 +142,19 @@ impl Parse for Image { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Image, ParseError<'i>> { - if let Ok(url) = input.try(|input| SpecifiedImageUrl::parse(context, input)) { + if let Ok(url) = input.r#try(|input| SpecifiedImageUrl::parse(context, input)) { return Ok(generic::Image::Url(url)); } - if let Ok(gradient) = input.try(|i| Gradient::parse(context, i)) { + if let Ok(gradient) = input.r#try(|i| Gradient::parse(context, i)) { return Ok(generic::Image::Gradient(Box::new(gradient))); } #[cfg(feature = "servo")] { - if let Ok(paint_worklet) = input.try(|i| PaintWorklet::parse(context, i)) { + if let Ok(paint_worklet) = input.r#try(|i| PaintWorklet::parse(context, i)) { return Ok(generic::Image::PaintWorklet(paint_worklet)); } } - if let Ok(image_rect) = input.try(|input| MozImageRect::parse(context, input)) { + if let Ok(image_rect) = input.r#try(|input| MozImageRect::parse(context, input)) { return Ok(generic::Image::Rect(Box::new(image_rect))); } Ok(generic::Image::Element(Image::parse_element(input)?)) @@ -166,13 +166,13 @@ impl Image { /// for insertion in the cascade. #[cfg(feature = "servo")] pub fn for_cascade(url: ServoUrl) -> Self { - use values::CssUrl; + use crate::values::CssUrl; generic::Image::Url(CssUrl::for_cascade(url)) } /// Parses a `-moz-element(# <element-id>)`. fn parse_element<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Atom, ParseError<'i>> { - input.try(|i| i.expect_function_matching("-moz-element"))?; + input.r#try(|i| i.expect_function_matching("-moz-element"))?; let location = input.current_source_location(); input.parse_nested_block(|i| match *i.next()? { Token::IDHash(ref id) => Ok(Atom::from(id.as_ref())), @@ -190,7 +190,7 @@ impl Image { input: &mut Parser<'i, 't>, ) -> Result<Image, ParseError<'i>> { if let Ok(url) = - input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input)) + input.r#try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input)) { return Ok(generic::Image::Url(url)); } @@ -350,7 +350,7 @@ impl Gradient { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - input.try(|i| { + input.r#try(|i| { let x = Component::parse(context, i)?; let y = Component::parse(context, i)?; @@ -413,13 +413,13 @@ impl Gradient { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(side) = input.try(|i| S::parse(context, i)) { + if let Ok(side) = input.r#try(|i| S::parse(context, i)) { return Ok(Component::Side(side)); } - if let Ok(number) = input.try(|i| NumberOrPercentage::parse(context, i)) { + if let Ok(number) = input.r#try(|i| NumberOrPercentage::parse(context, i)) { return Ok(Component::Number(number)); } - input.try(|i| i.expect_ident_matching("center"))?; + input.r#try(|i| i.expect_ident_matching("center"))?; Ok(Component::Center) } } @@ -477,7 +477,7 @@ impl Gradient { }; let mut items = input - .try(|i| { + .r#try(|i| { i.expect_comma()?; i.parse_comma_separated(|i| { let function = i.expect_function()?.clone(); @@ -572,16 +572,16 @@ impl GradientKind { input: &mut Parser<'i, 't>, compat_mode: &mut CompatMode, ) -> Result<Self, ParseError<'i>> { - let direction = if let Ok(d) = input.try(|i| LineDirection::parse(context, i, compat_mode)) - { - input.expect_comma()?; - d - } else { - match *compat_mode { - CompatMode::Modern => LineDirection::Vertical(Y::Bottom), - _ => LineDirection::Vertical(Y::Top), - } - }; + let direction = + if let Ok(d) = input.r#try(|i| LineDirection::parse(context, i, compat_mode)) { + input.expect_comma()?; + d + } else { + match *compat_mode { + CompatMode::Modern => LineDirection::Vertical(Y::Bottom), + _ => LineDirection::Vertical(Y::Top), + } + }; Ok(generic::GradientKind::Linear(direction)) } @@ -592,16 +592,16 @@ impl GradientKind { ) -> Result<Self, ParseError<'i>> { let (shape, position, angle, moz_position) = match *compat_mode { CompatMode::Modern => { - let shape = input.try(|i| EndingShape::parse(context, i, *compat_mode)); - let position = input.try(|i| { + let shape = input.r#try(|i| EndingShape::parse(context, i, *compat_mode)); + let position = input.r#try(|i| { i.expect_ident_matching("at")?; Position::parse(context, i) }); (shape, position.ok(), None, None) }, CompatMode::WebKit => { - let position = input.try(|i| Position::parse(context, i)); - let shape = input.try(|i| { + let position = input.r#try(|i| Position::parse(context, i)); + let shape = input.r#try(|i| { if position.is_ok() { i.expect_comma()?; } @@ -620,13 +620,13 @@ impl GradientKind { // cover | contain // and <color-stop> = <color> [ <percentage> | <length> ]? CompatMode::Moz => { - let mut position = input.try(|i| LegacyPosition::parse(context, i)); - let angle = input.try(|i| Angle::parse(context, i)).ok(); + let mut position = input.r#try(|i| LegacyPosition::parse(context, i)); + let angle = input.r#try(|i| Angle::parse(context, i)).ok(); if position.is_err() { - position = input.try(|i| LegacyPosition::parse(context, i)); + position = input.r#try(|i| LegacyPosition::parse(context, i)); } - let shape = input.try(|i| { + let shape = input.r#try(|i| { if position.is_ok() || angle.is_some() { i.expect_comma()?; } @@ -768,18 +768,18 @@ impl LineDirection { compat_mode: &mut CompatMode, ) -> Result<Self, ParseError<'i>> { let mut _angle = if *compat_mode == CompatMode::Moz { - input.try(|i| Angle::parse(context, i)).ok() + input.r#try(|i| Angle::parse(context, i)).ok() } else { // Gradients allow unitless zero angles as an exception, see: // https://github.com/w3c/csswg-drafts/issues/1162 - if let Ok(angle) = input.try(|i| Angle::parse_with_unitless(context, i)) { + if let Ok(angle) = input.r#try(|i| Angle::parse_with_unitless(context, i)) { return Ok(LineDirection::Angle(angle)); } None }; - input.try(|i| { - let to_ident = i.try(|i| i.expect_ident_matching("to")); + input.r#try(|i| { + let to_ident = i.r#try(|i| i.expect_ident_matching("to")); match *compat_mode { // `to` keyword is mandatory in modern syntax. CompatMode::Modern => to_ident?, @@ -801,9 +801,9 @@ impl LineDirection { { // `-moz-` prefixed linear gradient can be both Angle and Position. if *compat_mode == CompatMode::Moz { - let position = i.try(|i| LegacyPosition::parse(context, i)).ok(); + let position = i.r#try(|i| LegacyPosition::parse(context, i)).ok(); if _angle.is_none() { - _angle = i.try(|i| Angle::parse(context, i)).ok(); + _angle = i.r#try(|i| Angle::parse(context, i)).ok(); }; if _angle.is_none() && position.is_none() { @@ -813,14 +813,14 @@ impl LineDirection { } } - if let Ok(x) = i.try(X::parse) { - if let Ok(y) = i.try(Y::parse) { + if let Ok(x) = i.r#try(X::parse) { + if let Ok(y) = i.r#try(Y::parse) { return Ok(LineDirection::Corner(x, y)); } return Ok(LineDirection::Horizontal(x)); } let y = Y::parse(i)?; - if let Ok(x) = i.try(X::parse) { + if let Ok(x) = i.r#try(X::parse) { return Ok(LineDirection::Corner(x, y)); } Ok(LineDirection::Vertical(y)) @@ -850,19 +850,20 @@ impl EndingShape { input: &mut Parser<'i, 't>, compat_mode: CompatMode, ) -> Result<Self, ParseError<'i>> { - if let Ok(extent) = input.try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) { - if input.try(|i| i.expect_ident_matching("circle")).is_ok() { + if let Ok(extent) = input.r#try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) { + if input.r#try(|i| i.expect_ident_matching("circle")).is_ok() { return Ok(generic::EndingShape::Circle(Circle::Extent(extent))); } - let _ = input.try(|i| i.expect_ident_matching("ellipse")); + let _ = input.r#try(|i| i.expect_ident_matching("ellipse")); return Ok(generic::EndingShape::Ellipse(Ellipse::Extent(extent))); } - if input.try(|i| i.expect_ident_matching("circle")).is_ok() { - if let Ok(extent) = input.try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) { + if input.r#try(|i| i.expect_ident_matching("circle")).is_ok() { + if let Ok(extent) = input.r#try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) + { return Ok(generic::EndingShape::Circle(Circle::Extent(extent))); } if compat_mode == CompatMode::Modern { - if let Ok(length) = input.try(|i| Length::parse(context, i)) { + if let Ok(length) = input.r#try(|i| Length::parse(context, i)) { return Ok(generic::EndingShape::Circle(Circle::Radius(length))); } } @@ -870,12 +871,13 @@ impl EndingShape { ShapeExtent::FarthestCorner, ))); } - if input.try(|i| i.expect_ident_matching("ellipse")).is_ok() { - if let Ok(extent) = input.try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) { + if input.r#try(|i| i.expect_ident_matching("ellipse")).is_ok() { + if let Ok(extent) = input.r#try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) + { return Ok(generic::EndingShape::Ellipse(Ellipse::Extent(extent))); } if compat_mode == CompatMode::Modern { - let pair: Result<_, ParseError> = input.try(|i| { + let pair: Result<_, ParseError> = input.r#try(|i| { let x = LengthOrPercentage::parse(context, i)?; let y = LengthOrPercentage::parse(context, i)?; Ok((x, y)) @@ -891,10 +893,10 @@ impl EndingShape { // -moz- prefixed radial gradient doesn't allow EndingShape's Length or LengthOrPercentage // to come before shape keyword. Otherwise it conflicts with <position>. if compat_mode != CompatMode::Moz { - if let Ok(length) = input.try(|i| Length::parse(context, i)) { - if let Ok(y) = input.try(|i| LengthOrPercentage::parse(context, i)) { + if let Ok(length) = input.r#try(|i| Length::parse(context, i)) { + if let Ok(y) = input.r#try(|i| LengthOrPercentage::parse(context, i)) { if compat_mode == CompatMode::Modern { - let _ = input.try(|i| i.expect_ident_matching("ellipse")); + let _ = input.r#try(|i| i.expect_ident_matching("ellipse")); } return Ok(generic::EndingShape::Ellipse(Ellipse::Radii( length.into(), @@ -902,7 +904,7 @@ impl EndingShape { ))); } if compat_mode == CompatMode::Modern { - let y = input.try(|i| { + let y = input.r#try(|i| { i.expect_ident_matching("ellipse")?; LengthOrPercentage::parse(context, i) }); @@ -912,17 +914,17 @@ impl EndingShape { y, ))); } - let _ = input.try(|i| i.expect_ident_matching("circle")); + let _ = input.r#try(|i| i.expect_ident_matching("circle")); } return Ok(generic::EndingShape::Circle(Circle::Radius(length))); } } - input.try(|i| { + input.r#try(|i| { let x = Percentage::parse(context, i)?; - let y = if let Ok(y) = i.try(|i| LengthOrPercentage::parse(context, i)) { + let y = if let Ok(y) = i.r#try(|i| LengthOrPercentage::parse(context, i)) { if compat_mode == CompatMode::Modern { - let _ = i.try(|i| i.expect_ident_matching("ellipse")); + let _ = i.r#try(|i| i.expect_ident_matching("ellipse")); } y } else { @@ -963,7 +965,7 @@ impl GradientItem { loop { input.parse_until_before(Delimiter::Comma, |input| { if seen_stop { - if let Ok(hint) = input.try(|i| LengthOrPercentage::parse(context, i)) { + if let Ok(hint) = input.r#try(|i| LengthOrPercentage::parse(context, i)) { seen_stop = false; items.push(generic::GradientItem::InterpolationHint(hint)); return Ok(()); @@ -972,7 +974,7 @@ impl GradientItem { let stop = ColorStop::parse(context, input)?; - if let Ok(multi_position) = input.try(|i| LengthOrPercentage::parse(context, i)) { + if let Ok(multi_position) = input.r#try(|i| LengthOrPercentage::parse(context, i)) { let stop_color = stop.color.clone(); items.push(generic::GradientItem::ColorStop(stop)); items.push(generic::GradientItem::ColorStop(ColorStop { @@ -1008,7 +1010,7 @@ impl Parse for ColorStop { ) -> Result<Self, ParseError<'i>> { Ok(ColorStop { color: Color::parse(context, input)?, - position: input.try(|i| LengthOrPercentage::parse(context, i)).ok(), + position: input.r#try(|i| LengthOrPercentage::parse(context, i)).ok(), }) } } @@ -1022,7 +1024,7 @@ impl Parse for PaintWorklet { input.parse_nested_block(|input| { let name = Atom::from(&**input.expect_ident()?); let arguments = input - .try(|input| { + .r#try(|input| { input.expect_comma()?; input.parse_comma_separated(|input| SpecifiedValue::parse(input)) }) @@ -1037,7 +1039,7 @@ impl Parse for MozImageRect { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - input.try(|i| i.expect_function_matching("-moz-image-rect"))?; + input.r#try(|i| i.expect_function_matching("-moz-image-rect"))?; input.parse_nested_block(|i| { let string = i.expect_url_or_string()?; let url = SpecifiedImageUrl::parse_from_string(string.as_ref().to_owned(), context); diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 535cf6f65ee..4dd4ab42935 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -8,23 +8,25 @@ use super::{AllowQuirks, Number, Percentage, ToComputedValue}; use app_units::Au; +use crate::font_metrics::FontMetricsQueryResult; +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::{self, CSSPixelLength, Context, ExtremumLength}; +use crate::values::generics::length::{ + MaxLength as GenericMaxLength, MozLength as GenericMozLength, +}; +use crate::values::generics::NonNegative; +use crate::values::specified::calc::CalcNode; +use crate::values::{Auto, CSSFloat, Either, IsAuto, Normal}; use cssparser::{Parser, Token}; use euclid::Size2D; -use font_metrics::FontMetricsQueryResult; -use parser::{Parse, ParserContext}; use std::cmp; use std::ops::{Add, Mul}; use style_traits::values::specified::AllowedNumericType; use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind}; -use values::computed::{self, CSSPixelLength, Context, ExtremumLength}; -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 super::image::{ColorStop, EndingShape as GradientEndingShape, Gradient}; pub use super::image::{GradientKind, Image}; -pub use values::specified::calc::CalcLengthOrPercentage; +pub use crate::values::specified::calc::CalcLengthOrPercentage; /// Number of app units per pixel pub const AU_PER_PX: CSSFloat = 60.; @@ -1182,7 +1184,7 @@ impl LengthOrNumber { // We try to parse as a Number first because, for cases like // LengthOrNumber, we want "0" to be parsed as a plain Number rather // than a Length (0px); this matches the behaviour of all major browsers - if let Ok(v) = input.try(|i| Number::parse_non_negative(context, i)) { + if let Ok(v) = input.r#try(|i| Number::parse_non_negative(context, i)) { return Ok(Either::Second(v)); } @@ -1226,7 +1228,7 @@ impl MozLength { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - if let Ok(l) = input.try(ExtremumLength::parse) { + if let Ok(l) = input.r#try(ExtremumLength::parse) { return Ok(GenericMozLength::ExtremumLength(l)); } @@ -1278,7 +1280,7 @@ impl MaxLength { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - if let Ok(l) = input.try(ExtremumLength::parse) { + if let Ok(l) = input.r#try(ExtremumLength::parse) { return Ok(GenericMaxLength::ExtremumLength(l)); } diff --git a/components/style/values/specified/list.rs b/components/style/values/specified/list.rs index 3c0fb89258b..2ad38249385 100644 --- a/components/style/values/specified/list.rs +++ b/components/style/values/specified/list.rs @@ -4,8 +4,8 @@ //! `list` specified values. +use crate::parser::{Parse, ParserContext}; use cssparser::{Parser, Token}; -use parser::{Parse, ParserContext}; use servo_arc::Arc; use style_traits::{ParseError, StyleParseErrorKind}; #[cfg(feature = "gecko")] @@ -63,7 +63,7 @@ impl Parse for ListStyleType { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(style) = input.try(|i| CounterStyleOrNone::parse(context, i)) { + if let Ok(style) = input.r#try(|i| CounterStyleOrNone::parse(context, i)) { return Ok(ListStyleType::CounterStyle(style)); } @@ -97,7 +97,7 @@ impl Parse for Quotes { input: &mut Parser<'i, 't>, ) -> Result<Quotes, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(Quotes(Arc::new(Box::new([])))); diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 21fd4b86e94..0fb510543f7 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -11,17 +11,17 @@ use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as Generic 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 crate::context::QuirksMode; +use crate::parser::{Parse, ParserContext}; +use crate::values::serialize_atom_identifier; +use crate::values::specified::calc::CalcNode; +use crate::{Atom, Namespace, Prefix}; use cssparser::{Parser, Token}; use num_traits::One; -use parser::{Parse, ParserContext}; use std::f32; use std::fmt::{self, Write}; use style_traits::values::specified::AllowedNumericType; use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; -use values::serialize_atom_identifier; -use values::specified::calc::CalcNode; -use {Atom, Namespace, Prefix}; #[cfg(feature = "gecko")] pub use self::align::{AlignContent, AlignItems, AlignSelf, ContentDistribution}; @@ -359,7 +359,7 @@ impl NumberOrPercentage { input: &mut Parser<'i, 't>, type_: AllowedNumericType, ) -> Result<Self, ParseError<'i>> { - if let Ok(per) = input.try(|i| Percentage::parse_with_clamping_mode(context, i, type_)) { + if let Ok(per) = input.r#try(|i| Percentage::parse_with_clamping_mode(context, i, type_)) { return Ok(NumberOrPercentage::Percentage(per)); } @@ -695,7 +695,7 @@ impl ClipRect { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - use values::specified::Length; + use crate::values::specified::Length; fn parse_argument<'i, 't>( context: &ParserContext, @@ -703,7 +703,7 @@ impl ClipRect { allow_quirks: AllowQuirks, ) -> Result<Option<Length>, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("auto")) + .r#try(|input| input.expect_ident_matching("auto")) .is_ok() { Ok(None) @@ -720,7 +720,7 @@ impl ClipRect { let bottom; let left; - if input.try(|input| input.expect_comma()).is_ok() { + if input.r#try(|input| input.expect_comma()).is_ok() { right = parse_argument(context, input, allow_quirks)?; input.expect_comma()?; bottom = parse_argument(context, input, allow_quirks)?; @@ -751,7 +751,7 @@ impl ClipRectOrAuto { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - if let Ok(v) = input.try(|i| ClipRect::parse_quirky(context, i, allow_quirks)) { + if let Ok(v) = input.r#try(|i| ClipRect::parse_quirky(context, i, allow_quirks)) { Ok(Either::First(v)) } else { Auto::parse(context, input).map(Either::Second) @@ -816,8 +816,8 @@ impl Attr { ) -> Result<Attr, ParseError<'i>> { // Syntax is `[namespace? `|`]? ident` // no spaces allowed - let first = input.try(|i| i.expect_ident_cloned()).ok(); - if let Ok(token) = input.try(|i| i.next_including_whitespace().map(|t| t.clone())) { + let first = input.r#try(|i| i.expect_ident_cloned()).ok(); + if let Ok(token) = input.r#try(|i| i.next_including_whitespace().map(|t| t.clone())) { match token { Token::Delim('|') => { let location = input.current_source_location(); diff --git a/components/style/values/specified/motion.rs b/components/style/values/specified/motion.rs index b591d43a2bb..632b29a45b9 100644 --- a/components/style/values/specified/motion.rs +++ b/components/style/values/specified/motion.rs @@ -4,10 +4,10 @@ //! Specified types for CSS values that are related to motion path. +use crate::parser::{Parse, ParserContext}; +use crate::values::specified::SVGPathData; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::{ParseError, StyleParseErrorKind}; -use values::specified::SVGPathData; /// The offset-path value. /// @@ -50,7 +50,7 @@ impl Parse for OffsetPath { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { // Parse none. - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(OffsetPath::none()); } diff --git a/components/style/values/specified/outline.rs b/components/style/values/specified/outline.rs index afe74dc39f3..46f1acd0b89 100644 --- a/components/style/values/specified/outline.rs +++ b/components/style/values/specified/outline.rs @@ -4,11 +4,11 @@ //! Specified values for outline properties +use crate::parser::{Parse, ParserContext}; +use crate::values::specified::BorderStyle; use cssparser::Parser; -use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use style_traits::ParseError; -use values::specified::BorderStyle; #[derive( Clone, @@ -53,7 +53,7 @@ impl Parse for OutlineStyle { _context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<OutlineStyle, ParseError<'i>> { - if let Ok(border_style) = input.try(BorderStyle::parse) { + if let Ok(border_style) = input.r#try(BorderStyle::parse) { if let BorderStyle::Hidden = border_style { return Err(input .new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into()))); diff --git a/components/style/values/specified/percentage.rs b/components/style/values/specified/percentage.rs index 55c5216fb17..2cdbff7eaea 100644 --- a/components/style/values/specified/percentage.rs +++ b/components/style/values/specified/percentage.rs @@ -4,15 +4,15 @@ //! Specified percentages. +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::percentage::Percentage as ComputedPercentage; +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::specified::calc::CalcNode; +use crate::values::{serialize_percentage, CSSFloat}; use cssparser::{Parser, Token}; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::values::specified::AllowedNumericType; 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/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index 0459d2818d8..8444eb0a88f 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -7,22 +7,24 @@ //! //! [position]: https://drafts.csswg.org/css-backgrounds-3/#position +use crate::hash::FxHashMap; +use crate::parser::{Parse, ParserContext}; +use crate::str::HTML_SPACE_CHARACTERS; +use crate::values::computed::{ + CalcLengthOrPercentage, LengthOrPercentage as ComputedLengthOrPercentage, +}; +use crate::values::computed::{Context, Percentage, ToComputedValue}; +use crate::values::generics::position::Position as GenericPosition; +use crate::values::generics::position::ZIndex as GenericZIndex; +use crate::values::specified::transform::OriginComponent; +use crate::values::specified::{AllowQuirks, Integer, LengthOrPercentage}; +use crate::values::{Either, None_}; use cssparser::Parser; -use hash::FxHashMap; -use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use servo_arc::Arc; use std::fmt::{self, Write}; use std::ops::Range; -use str::HTML_SPACE_CHARACTERS; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -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::transform::OriginComponent; -use values::specified::{AllowQuirks, Integer, LengthOrPercentage}; -use values::{Either, None_}; /// The specified value of a CSS `<position>` pub type Position = GenericPosition<HorizontalPosition, VerticalPosition>; @@ -100,28 +102,28 @@ impl Position { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - match input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) { + match input.r#try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) { Ok(x_pos @ PositionComponent::Center) => { if let Ok(y_pos) = - input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) + input.r#try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) { return Ok(Self::new(x_pos, y_pos)); } let x_pos = input - .try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) + .r#try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) .unwrap_or(x_pos); let y_pos = PositionComponent::Center; return Ok(Self::new(x_pos, y_pos)); }, Ok(PositionComponent::Side(x_keyword, lop)) => { - if input.try(|i| i.expect_ident_matching("center")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("center")).is_ok() { let x_pos = PositionComponent::Side(x_keyword, lop); let y_pos = PositionComponent::Center; return Ok(Self::new(x_pos, y_pos)); } - if let Ok(y_keyword) = input.try(Y::parse) { + if let Ok(y_keyword) = input.r#try(Y::parse) { let y_lop = input - .try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + .r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) .ok(); let x_pos = PositionComponent::Side(x_keyword, lop); let y_pos = PositionComponent::Side(y_keyword, y_lop); @@ -132,30 +134,30 @@ impl Position { return Ok(Self::new(x_pos, y_pos)); }, Ok(x_pos @ PositionComponent::Length(_)) => { - if let Ok(y_keyword) = input.try(Y::parse) { + if let Ok(y_keyword) = input.r#try(Y::parse) { let y_pos = PositionComponent::Side(y_keyword, None); return Ok(Self::new(x_pos, y_pos)); } if let Ok(y_lop) = - input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) { let y_pos = PositionComponent::Length(y_lop); return Ok(Self::new(x_pos, y_pos)); } let y_pos = PositionComponent::Center; - let _ = input.try(|i| i.expect_ident_matching("center")); + let _ = input.r#try(|i| i.expect_ident_matching("center")); return Ok(Self::new(x_pos, y_pos)); }, Err(_) => {}, } let y_keyword = Y::parse(input)?; - let lop_and_x_pos: Result<_, ParseError> = input.try(|i| { + let lop_and_x_pos: Result<_, ParseError> = input.r#try(|i| { let y_lop = i - .try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + .r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) .ok(); - if let Ok(x_keyword) = i.try(X::parse) { + if let Ok(x_keyword) = i.r#try(X::parse) { let x_lop = i - .try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + .r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) .ok(); let x_pos = PositionComponent::Side(x_keyword, x_lop); return Ok((y_lop, x_pos)); @@ -228,15 +230,16 @@ impl<S: Parse> PositionComponent<S> { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("center")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("center")).is_ok() { return Ok(PositionComponent::Center); } - if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) { + if let Ok(lop) = input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + { return Ok(PositionComponent::Length(lop)); } let keyword = S::parse(context, input)?; let lop = input - .try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + .r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) .ok(); Ok(PositionComponent::Side(keyword, lop)) } @@ -357,51 +360,51 @@ impl LegacyPosition { input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { - match input.try(|i| OriginComponent::parse(context, i)) { + match input.r#try(|i| OriginComponent::parse(context, i)) { Ok(x_pos @ OriginComponent::Center) => { - if let Ok(y_pos) = input.try(|i| OriginComponent::parse(context, i)) { + if let Ok(y_pos) = input.r#try(|i| OriginComponent::parse(context, i)) { return Ok(Self::new(x_pos, y_pos)); } let x_pos = input - .try(|i| OriginComponent::parse(context, i)) + .r#try(|i| OriginComponent::parse(context, i)) .unwrap_or(x_pos); let y_pos = OriginComponent::Center; return Ok(Self::new(x_pos, y_pos)); }, Ok(OriginComponent::Side(x_keyword)) => { - if let Ok(y_keyword) = input.try(Y::parse) { + if let Ok(y_keyword) = input.r#try(Y::parse) { let x_pos = OriginComponent::Side(x_keyword); let y_pos = OriginComponent::Side(y_keyword); return Ok(Self::new(x_pos, y_pos)); } let x_pos = OriginComponent::Side(x_keyword); if let Ok(y_lop) = - input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) { return Ok(Self::new(x_pos, OriginComponent::Length(y_lop))); } - let _ = input.try(|i| i.expect_ident_matching("center")); + let _ = input.r#try(|i| i.expect_ident_matching("center")); return Ok(Self::new(x_pos, OriginComponent::Center)); }, Ok(x_pos @ OriginComponent::Length(_)) => { - if let Ok(y_keyword) = input.try(Y::parse) { + if let Ok(y_keyword) = input.r#try(Y::parse) { let y_pos = OriginComponent::Side(y_keyword); return Ok(Self::new(x_pos, y_pos)); } if let Ok(y_lop) = - input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + input.r#try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) { let y_pos = OriginComponent::Length(y_lop); return Ok(Self::new(x_pos, y_pos)); } - let _ = input.try(|i| i.expect_ident_matching("center")); + let _ = input.r#try(|i| i.expect_ident_matching("center")); return Ok(Self::new(x_pos, OriginComponent::Center)); }, Err(_) => {}, } let y_keyword = Y::parse(input)?; - let x_pos: Result<_, ParseError> = input.try(|i| { - if let Ok(x_keyword) = i.try(X::parse) { + let x_pos: Result<_, ParseError> = input.r#try(|i| { + if let Ok(x_keyword) = i.r#try(X::parse) { let x_pos = OriginComponent::Side(x_keyword); return Ok(x_pos); } @@ -646,7 +649,7 @@ impl Parse for TemplateAreas { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { let mut strings = vec![]; - while let Ok(string) = input.try(|i| i.expect_string().map(|s| s.as_ref().into())) { + while let Ok(string) = input.r#try(|i| i.expect_string().map(|s| s.as_ref().into())) { strings.push(string); } @@ -740,7 +743,7 @@ impl Parse for ZIndex { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("auto")).is_ok() { return Ok(GenericZIndex::Auto); } Ok(GenericZIndex::Integer(Integer::parse(context, input)?)) diff --git a/components/style/values/specified/rect.rs b/components/style/values/specified/rect.rs index e8eed7493af..c833bbe72cd 100644 --- a/components/style/values/specified/rect.rs +++ b/components/style/values/specified/rect.rs @@ -4,11 +4,11 @@ //! Specified types for CSS borders. +use crate::parser::ParserContext; +use crate::values::generics::rect::Rect; +use crate::values::specified::length::LengthOrNumber; use cssparser::Parser; -use parser::ParserContext; use style_traits::ParseError; -use values::generics::rect::Rect; -use values::specified::length::LengthOrNumber; /// A specified rectangle made of four `<length-or-number>` values. pub type LengthOrNumberRect = Rect<LengthOrNumber>; diff --git a/components/style/values/specified/resolution.rs b/components/style/values/specified/resolution.rs index 0878c776272..f7e76c003df 100644 --- a/components/style/values/specified/resolution.rs +++ b/components/style/values/specified/resolution.rs @@ -6,10 +6,10 @@ //! //! https://drafts.csswg.org/css-values/#resolution +use crate::parser::{Parse, ParserContext}; +use crate::values::CSSFloat; use cssparser::{Parser, Token}; -use parser::{Parse, ParserContext}; use style_traits::{ParseError, StyleParseErrorKind}; -use values::CSSFloat; /// A specified resolution. #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] diff --git a/components/style/values/specified/source_size_list.rs b/components/style/values/specified/source_size_list.rs index e00f4ee1d5d..365e5cc27d7 100644 --- a/components/style/values/specified/source_size_list.rs +++ b/components/style/values/specified/source_size_list.rs @@ -5,15 +5,15 @@ //! https://html.spec.whatwg.org/multipage/#source-size-list use app_units::Au; +use crate::media_queries::{Device, MediaCondition}; +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::{self, ToComputedValue}; +use crate::values::specified::{Length, NoCalcLength, ViewportPercentageLength}; use cssparser::{Delimiter, Parser, Token}; #[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; -use media_queries::{Device, MediaCondition}; -use parser::{Parse, ParserContext}; use selectors::context::QuirksMode; use style_traits::ParseError; -use values::computed::{self, ToComputedValue}; -use values::specified::{Length, NoCalcLength, ViewportPercentageLength}; /// A value for a `<source-size>`: /// @@ -92,7 +92,7 @@ impl Parse for SourceSizeOrLength { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(size) = input.try(|input| SourceSize::parse(context, input)) { + if let Ok(size) = input.r#try(|input| SourceSize::parse(context, input)) { return Ok(SourceSizeOrLength::SourceSize(size)); } diff --git a/components/style/values/specified/svg.rs b/components/style/values/specified/svg.rs index 4b64e8fe537..24b4af4d637 100644 --- a/components/style/values/specified/svg.rs +++ b/components/style/values/specified/svg.rs @@ -4,17 +4,19 @@ //! Specified types for SVG properties. +use crate::parser::{Parse, ParserContext}; +use crate::values::generics::svg as generic; +use crate::values::specified::color::Color; +use crate::values::specified::url::SpecifiedUrl; +use crate::values::specified::{ + LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber, +}; +use crate::values::specified::{Number, Opacity}; +use crate::values::CustomIdent; use cssparser::Parser; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::{CommaWithSpace, CssWriter, ParseError, Separator}; use style_traits::{StyleParseErrorKind, ToCss}; -use values::generics::svg as generic; -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<Color, SpecifiedUrl>; @@ -61,7 +63,7 @@ impl Parse for SVGLength { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { input - .try(|i| SvgLengthOrPercentageOrNumber::parse(context, i)) + .r#try(|i| SvgLengthOrPercentageOrNumber::parse(context, i)) .map(Into::into) .or_else(|_| parse_context_value(input, generic::SVGLength::ContextValue)) } @@ -87,7 +89,7 @@ impl Parse for SVGWidth { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { input - .try(|i| NonNegativeSvgLengthOrPercentageOrNumber::parse(context, i)) + .r#try(|i| NonNegativeSvgLengthOrPercentageOrNumber::parse(context, i)) .map(Into::into) .or_else(|_| parse_context_value(input, generic::SVGLength::ContextValue)) } @@ -107,13 +109,13 @@ impl Parse for SVGStrokeDashArray { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(values) = input.try(|i| { + if let Ok(values) = input.r#try(|i| { CommaWithSpace::parse(i, |i| { NonNegativeSvgLengthOrPercentageOrNumber::parse(context, i) }) }) { Ok(generic::SVGStrokeDashArray::Values(values)) - } else if let Ok(_) = input.try(|i| i.expect_ident_matching("none")) { + } else if let Ok(_) = input.r#try(|i| i.expect_ident_matching("none")) { Ok(generic::SVGStrokeDashArray::Values(vec![])) } else { parse_context_value(input, generic::SVGStrokeDashArray::ContextValue) @@ -129,7 +131,7 @@ impl Parse for SVGOpacity { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(opacity) = input.try(|i| Opacity::parse(context, i)) { + if let Ok(opacity) = input.r#try(|i| Opacity::parse(context, i)) { return Ok(generic::SVGOpacity::Opacity(opacity)); } @@ -194,7 +196,7 @@ impl Parse for SVGPaintOrder { _context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<SVGPaintOrder, ParseError<'i>> { - if let Ok(()) = input.try(|i| i.expect_ident_matching("normal")) { + if let Ok(()) = input.r#try(|i| i.expect_ident_matching("normal")) { return Ok(SVGPaintOrder::normal()); } @@ -205,7 +207,7 @@ impl Parse for SVGPaintOrder { let mut pos = 0; loop { - let result: Result<_, ParseError> = input.try(|input| { + let result: Result<_, ParseError> = input.r#try(|input| { try_match_ident_ignore_ascii_case! { input, "fill" => Ok(PaintOrder::Fill), "stroke" => Ok(PaintOrder::Stroke), diff --git a/components/style/values/specified/svg_path.rs b/components/style/values/specified/svg_path.rs index 02d19bffcf4..94311cdef7b 100644 --- a/components/style/values/specified/svg_path.rs +++ b/components/style/values/specified/svg_path.rs @@ -4,17 +4,17 @@ //! Specified types for SVG Path. +use crate::parser::{Parse, ParserContext}; +use crate::values::animated::{Animate, Procedure, ToAnimatedZero}; +use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; +use crate::values::CSSFloat; use cssparser::Parser; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use std::iter::{Cloned, Peekable}; use std::ops::AddAssign; use std::slice; use style_traits::values::SequenceWriter; 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. /// diff --git a/components/style/values/specified/table.rs b/components/style/values/specified/table.rs index 0dd0755f95a..9b13c7b1941 100644 --- a/components/style/values/specified/table.rs +++ b/components/style/values/specified/table.rs @@ -4,8 +4,8 @@ //! Specified types for table properties. +use crate::parser::{Parse, ParserContext}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::{ParseError, StyleParseErrorKind}; #[derive( diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 32405076054..63664451b5b 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -4,27 +4,29 @@ //! Specified types for text properties. +use crate::parser::{Parse, ParserContext}; +use crate::properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode; +use crate::values::computed::text::LineHeight as ComputedLineHeight; +use crate::values::computed::text::TextEmphasisKeywordValue as ComputedTextEmphasisKeywordValue; +use crate::values::computed::text::TextEmphasisStyle as ComputedTextEmphasisStyle; +use crate::values::computed::text::TextOverflow as ComputedTextOverflow; +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::generics::text::InitialLetter as GenericInitialLetter; +use crate::values::generics::text::LineHeight as GenericLineHeight; +use crate::values::generics::text::MozTabSize as GenericMozTabSize; +use crate::values::generics::text::Spacing; +use crate::values::specified::length::{ + FontRelativeLength, Length, LengthOrPercentage, NoCalcLength, +}; +use crate::values::specified::length::{NonNegativeLength, NonNegativeLengthOrPercentage}; +use crate::values::specified::{AllowQuirks, Integer, NonNegativeNumber, Number}; use cssparser::{Parser, Token}; -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 unicode_segmentation::UnicodeSegmentation; -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::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<Number, Integer>; @@ -43,11 +45,11 @@ impl Parse for InitialLetter { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("normal")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("normal")).is_ok() { return Ok(GenericInitialLetter::Normal); } let size = Number::parse_at_least_one(context, input)?; - let sink = input.try(|i| Integer::parse_positive(context, i)).ok(); + let sink = input.r#try(|i| Integer::parse_positive(context, i)).ok(); Ok(GenericInitialLetter::Specified(size, sink)) } } @@ -79,10 +81,10 @@ impl Parse for LineHeight { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(number) = input.try(|i| NonNegativeNumber::parse(context, i)) { + if let Ok(number) = input.r#try(|i| NonNegativeNumber::parse(context, i)) { return Ok(GenericLineHeight::Number(number)); } - if let Ok(nlop) = input.try(|i| NonNegativeLengthOrPercentage::parse(context, i)) { + if let Ok(nlop) = input.r#try(|i| NonNegativeLengthOrPercentage::parse(context, i)) { return Ok(GenericLineHeight::Length(nlop)); } let location = input.current_source_location(); @@ -107,8 +109,8 @@ impl ToComputedValue for LineHeight { #[inline] fn to_computed_value(&self, context: &Context) -> Self::ComputedValue { - use values::computed::Length as ComputedLength; - use values::specified::length::FontBaseSize; + use crate::values::computed::Length as ComputedLength; + use crate::values::specified::length::FontBaseSize; match *self { GenericLineHeight::Normal => GenericLineHeight::Normal, #[cfg(feature = "gecko")] @@ -213,7 +215,7 @@ impl Parse for TextOverflow { ) -> Result<TextOverflow, ParseError<'i>> { let first = TextOverflowSide::parse(context, input)?; let second = input - .try(|input| TextOverflowSide::parse(context, input)) + .r#try(|input| TextOverflowSide::parse(context, input)) .ok(); Ok(TextOverflow { first, second }) } @@ -293,14 +295,14 @@ macro_rules! impl_text_decoration_line { ) -> Result<TextDecorationLine, ParseError<'i>> { let mut result = TextDecorationLine::NONE; if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(result); } loop { - let result = input.try(|input| { + let result = input.r#try(|input| { let ident = input.expect_ident().map_err(|_| ())?; match_ignore_ascii_case! { ident, $( @@ -469,7 +471,7 @@ impl Parse for TextAlign { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { // MozCenterOrInherit cannot be parsed, only set directly on the elements - if let Ok(key) = input.try(TextAlignKeyword::parse) { + if let Ok(key) = input.r#try(TextAlignKeyword::parse) { return Ok(TextAlign::Keyword(key)); } #[cfg(feature = "gecko")] @@ -700,22 +702,22 @@ impl Parse for TextEmphasisStyle { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(TextEmphasisStyle::None); } - if let Ok(s) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned())) { + if let Ok(s) = input.r#try(|i| i.expect_string().map(|s| s.as_ref().to_owned())) { // Handle <string> return Ok(TextEmphasisStyle::String(s)); } // Handle a pair of keywords - let mut shape = input.try(TextEmphasisShapeKeyword::parse).ok(); - let fill = input.try(TextEmphasisFillMode::parse).ok(); + let mut shape = input.r#try(TextEmphasisShapeKeyword::parse).ok(); + let fill = input.r#try(TextEmphasisFillMode::parse).ok(); if shape.is_none() { - shape = input.try(TextEmphasisShapeKeyword::parse).ok(); + shape = input.r#try(TextEmphasisShapeKeyword::parse).ok(); } // At least one of shape or fill must be handled @@ -815,7 +817,7 @@ impl Parse for TextEmphasisPosition { input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { if let Ok(horizontal) = - input.try(|input| TextEmphasisHorizontalWritingModeValue::parse(input)) + input.r#try(|input| TextEmphasisHorizontalWritingModeValue::parse(input)) { let vertical = TextEmphasisVerticalWritingModeValue::parse(input)?; Ok(TextEmphasisPosition(horizontal, vertical)) @@ -867,7 +869,7 @@ impl Parse for MozTabSize { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if let Ok(number) = input.try(|i| NonNegativeNumber::parse(context, i)) { + if let Ok(number) = input.r#try(|i| NonNegativeNumber::parse(context, i)) { // Numbers need to be parsed first because `0` must be recognised // as the number `0` and not the length `0px`. return Ok(GenericMozTabSize::Number(number)); diff --git a/components/style/values/specified/time.rs b/components/style/values/specified/time.rs index bca7c6b0636..120827b579b 100644 --- a/components/style/values/specified/time.rs +++ b/components/style/values/specified/time.rs @@ -4,15 +4,15 @@ //! Specified time values. +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::time::Time as ComputedTime; +use crate::values::computed::{Context, ToComputedValue}; +use crate::values::specified::calc::CalcNode; +use crate::values::CSSFloat; use cssparser::{Parser, Token}; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::values::specified::AllowedNumericType; 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/components/style/values/specified/transform.rs b/components/style/values/specified/transform.rs index d397d3d3607..51c38a30ba8 100644 --- a/components/style/values/specified/transform.rs +++ b/components/style/values/specified/transform.rs @@ -4,17 +4,17 @@ //! Specified types for CSS values that are related to transformations. +use crate::parser::{Parse, ParserContext}; +use crate::values::computed::{Context, LengthOrPercentage as ComputedLengthOrPercentage}; +use crate::values::computed::{Percentage as ComputedPercentage, ToComputedValue}; +use crate::values::generics::transform as generic; +use crate::values::generics::transform::{Matrix, Matrix3D}; +use crate::values::specified::position::{Side, X, Y}; +use crate::values::specified::{self, Angle, Integer, Length, LengthOrPercentage, Number}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use style_traits::{ParseError, StyleParseErrorKind}; -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::position::{Side, X, Y}; -use values::specified::{self, Angle, Integer, Length, LengthOrPercentage, Number}; -pub use values::generics::transform::TransformStyle; +pub use crate::values::generics::transform::TransformStyle; /// A single operation in a specified CSS `transform` pub type TransformOperation = @@ -38,7 +38,7 @@ impl Transform { use style_traits::{Separator, Space}; if input - .try(|input| input.expect_ident_matching("none")) + .r#try(|input| input.expect_ident_matching("none")) .is_ok() { return Ok(generic::Transform(Vec::new())); @@ -106,7 +106,7 @@ impl Transform { }, "translate" => { let sx = specified::LengthOrPercentage::parse(context, input)?; - if input.try(|input| input.expect_comma()).is_ok() { + if input.r#try(|input| input.expect_comma()).is_ok() { let sy = specified::LengthOrPercentage::parse(context, input)?; Ok(generic::TransformOperation::Translate(sx, Some(sy))) } else { @@ -135,7 +135,7 @@ impl Transform { }, "scale" => { let sx = Number::parse(context, input)?; - if input.try(|input| input.expect_comma()).is_ok() { + if input.r#try(|input| input.expect_comma()).is_ok() { let sy = Number::parse(context, input)?; Ok(generic::TransformOperation::Scale(sx, Some(sy))) } else { @@ -191,7 +191,7 @@ impl Transform { }, "skew" => { let ax = specified::Angle::parse_with_unitless(context, input)?; - if input.try(|input| input.expect_comma()).is_ok() { + if input.r#try(|input| input.expect_comma()).is_ok() { let ay = specified::Angle::parse_with_unitless(context, input)?; Ok(generic::TransformOperation::Skew(ax, Some(ay))) } else { @@ -248,17 +248,17 @@ impl Parse for TransformOrigin { ) -> Result<Self, ParseError<'i>> { let parse_depth = |input: &mut Parser| { input - .try(|i| Length::parse(context, i)) + .r#try(|i| Length::parse(context, i)) .unwrap_or(Length::from_px(0.)) }; - match input.try(|i| OriginComponent::parse(context, i)) { + match input.r#try(|i| OriginComponent::parse(context, i)) { Ok(x_origin @ OriginComponent::Center) => { - if let Ok(y_origin) = input.try(|i| OriginComponent::parse(context, i)) { + if let Ok(y_origin) = input.r#try(|i| OriginComponent::parse(context, i)) { let depth = parse_depth(input); return Ok(Self::new(x_origin, y_origin, depth)); } let y_origin = OriginComponent::Center; - if let Ok(x_keyword) = input.try(X::parse) { + if let Ok(x_keyword) = input.r#try(X::parse) { let x_origin = OriginComponent::Side(x_keyword); let depth = parse_depth(input); return Ok(Self::new(x_origin, y_origin, depth)); @@ -267,7 +267,7 @@ impl Parse for TransformOrigin { return Ok(Self::new(x_origin, y_origin, depth)); }, Ok(x_origin) => { - if let Ok(y_origin) = input.try(|i| OriginComponent::parse(context, i)) { + if let Ok(y_origin) = input.r#try(|i| OriginComponent::parse(context, i)) { let depth = parse_depth(input); return Ok(Self::new(x_origin, y_origin, depth)); } @@ -279,12 +279,12 @@ impl Parse for TransformOrigin { } let y_keyword = Y::parse(input)?; let y_origin = OriginComponent::Side(y_keyword); - if let Ok(x_keyword) = input.try(X::parse) { + if let Ok(x_keyword) = input.r#try(X::parse) { let x_origin = OriginComponent::Side(x_keyword); let depth = parse_depth(input); return Ok(Self::new(x_origin, y_origin, depth)); } - if input.try(|i| i.expect_ident_matching("center")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("center")).is_ok() { let x_origin = OriginComponent::Center; let depth = parse_depth(input); return Ok(Self::new(x_origin, y_origin, depth)); @@ -303,10 +303,10 @@ where context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("center")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("center")).is_ok() { return Ok(OriginComponent::Center); } - if let Ok(lop) = input.try(|i| LengthOrPercentage::parse(context, i)) { + if let Ok(lop) = input.r#try(|i| LengthOrPercentage::parse(context, i)) { return Ok(OriginComponent::Length(lop)); } let keyword = S::parse(context, input)?; @@ -353,11 +353,11 @@ impl Parse for Rotate { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(generic::Rotate::None); } - if let Ok(rx) = input.try(|i| Number::parse(context, i)) { + if let Ok(rx) = input.r#try(|i| Number::parse(context, i)) { // 'rotate: <number>{3} <angle>' let ry = Number::parse(context, input)?; let rz = Number::parse(context, input)?; @@ -379,13 +379,13 @@ impl Parse for Translate { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(generic::Translate::None); } let tx = specified::LengthOrPercentage::parse(context, input)?; - if let Ok(ty) = input.try(|i| specified::LengthOrPercentage::parse(context, i)) { - if let Ok(tz) = input.try(|i| specified::Length::parse(context, i)) { + if let Ok(ty) = input.r#try(|i| specified::LengthOrPercentage::parse(context, i)) { + if let Ok(tz) = input.r#try(|i| specified::Length::parse(context, i)) { // 'translate: <length-percentage> <length-percentage> <length>' return Ok(generic::Translate::Translate3D(tx, ty, tz)); } @@ -407,13 +407,13 @@ impl Parse for Scale { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("none")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("none")).is_ok() { return Ok(generic::Scale::None); } let sx = Number::parse(context, input)?; - if let Ok(sy) = input.try(|i| Number::parse(context, i)) { - if let Ok(sz) = input.try(|i| Number::parse(context, i)) { + if let Ok(sy) = input.r#try(|i| Number::parse(context, i)) { + if let Ok(sz) = input.r#try(|i| Number::parse(context, i)) { // 'scale: <number> <number> <number>' return Ok(generic::Scale::Scale3D(sx, sy, sz)); } diff --git a/components/style/values/specified/ui.rs b/components/style/values/specified/ui.rs index ec930b28c00..e3ea599aa4c 100644 --- a/components/style/values/specified/ui.rs +++ b/components/style/values/specified/ui.rs @@ -4,16 +4,16 @@ //! Specified types for UI properties. +use crate::parser::{Parse, ParserContext}; +use crate::values::generics::ui as generics; +use crate::values::specified::color::Color; +use crate::values::specified::url::SpecifiedImageUrl; +use crate::values::specified::Number; +use crate::values::{Auto, Either}; use cssparser::Parser; -use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use style_traits::cursor::CursorKind; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use values::generics::ui as generics; -use values::specified::color::Color; -use values::specified::url::SpecifiedImageUrl; -use values::specified::Number; -use values::{Auto, Either}; /// auto | <color> pub type ColorOrAuto = Either<Color, Auto>; @@ -32,7 +32,7 @@ impl Parse for Cursor { ) -> Result<Self, ParseError<'i>> { let mut images = vec![]; loop { - match input.try(|input| CursorImage::parse(context, input)) { + match input.r#try(|input| CursorImage::parse(context, input)) { Ok(image) => images.push(image), Err(_) => break, } @@ -64,7 +64,7 @@ impl Parse for CursorImage { ) -> Result<Self, ParseError<'i>> { Ok(Self { url: SpecifiedImageUrl::parse(context, input)?, - hotspot: match input.try(|input| Number::parse(context, input)) { + hotspot: match input.r#try(|input| Number::parse(context, input)) { Ok(number) => Some((number, Number::parse(context, input)?)), Err(_) => None, }, @@ -131,7 +131,7 @@ impl Parse for ScrollbarColor { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { + if input.r#try(|i| i.expect_ident_matching("auto")).is_ok() { return Ok(generics::ScrollbarColor::Auto); } Ok(generics::ScrollbarColor::Colors { diff --git a/components/style/values/specified/url.rs b/components/style/values/specified/url.rs index fe68c3143f5..50f2079de5a 100644 --- a/components/style/values/specified/url.rs +++ b/components/style/values/specified/url.rs @@ -4,12 +4,12 @@ //! Common handling for the specified value CSS url() values. -use values::generics::url::UrlOrNone as GenericUrlOrNone; +use crate::values::generics::url::UrlOrNone as GenericUrlOrNone; +#[cfg(feature = "servo")] +pub use crate::servo::url::{SpecifiedImageUrl, SpecifiedUrl}; #[cfg(feature = "gecko")] pub use gecko::url::{SpecifiedImageUrl, SpecifiedUrl}; -#[cfg(feature = "servo")] -pub use servo::url::{SpecifiedImageUrl, SpecifiedUrl}; /// Specified <url> | <none> pub type UrlOrNone = GenericUrlOrNone<SpecifiedUrl>; |