diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-11-01 14:09:54 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-11-10 17:47:28 +0100 |
commit | a15d33a10e8a0aa1c02fa44ede50a63b95606b8f (patch) | |
tree | 5b0ef37530e77e646c2b6bc7df3d95e756607e77 /components/style/values | |
parent | e1fcffb336d763d851f14fae5cda464209552bb2 (diff) | |
download | servo-a15d33a10e8a0aa1c02fa44ede50a63b95606b8f.tar.gz servo-a15d33a10e8a0aa1c02fa44ede50a63b95606b8f.zip |
`cargo fix --edition`
Diffstat (limited to 'components/style/values')
85 files changed, 748 insertions, 713 deletions
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>; |