From 8f215a844464139d7341bc3977971260cf7f5886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 17 Jun 2020 23:40:30 +0000 Subject: [PATCH] style: Port the style crate to rust 2018. Differential Revision: https://phabricator.services.mozilla.com/D80101 --- components/style/Cargo.toml | 1 + components/style/build_gecko.rs | 2 +- components/style/dom.rs | 2 +- components/style/gecko_bindings/sugar/ownership.rs | 2 +- components/style/matching.rs | 9 ++++++--- .../properties/helpers/animated_properties.mako.rs | 2 +- components/style/values/computed/length.rs | 10 +++++----- components/style/values/generics/image.rs | 2 +- components/style/values/generics/ui.rs | 2 +- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 956a2c3f3d7..4baf6d381ef 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -6,6 +6,7 @@ license = "MPL-2.0" publish = false build = "build.rs" +edition = "2018" # https://github.com/rust-lang/cargo/issues/3544 links = "servo_style_crate" diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index dfd2a213d99..1e93660936a 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -318,7 +318,7 @@ fn generate_structs() { fixups.push(Fixup { pat: format!("\\broot\\s*::\\s*{}\\b", gecko), - rep: format!("::gecko_bindings::structs::{}", gecko_name), + rep: format!("crate::gecko_bindings::structs::{}", gecko_name), }); builder.blacklist_type(gecko).raw_line(format!( "pub type {0}{2} = {1}{2};", diff --git a/components/style/dom.rs b/components/style/dom.rs index 9c4ebd28d1e..a61739b920e 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -816,7 +816,7 @@ pub trait TElement: Self: 'a, F: FnMut(&'a CascadeData, Self), { - use rule_collector::containing_shadow_ignoring_svg_use; + use crate::rule_collector::containing_shadow_ignoring_svg_use; let target = self.rule_hash_target(); if !target.matches_user_and_author_rules() { diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs index 366e4619c68..249134169f5 100644 --- a/components/style/gecko_bindings/sugar/ownership.rs +++ b/components/style/gecko_bindings/sugar/ownership.rs @@ -4,7 +4,7 @@ //! Helpers for different FFI pointer kinds that Gecko's FFI layer uses. -use gecko_bindings::structs::root::mozilla::detail::CopyablePtr; +use crate::gecko_bindings::structs::root::mozilla::detail::CopyablePtr; use servo_arc::{Arc, RawOffsetArc}; use std::marker::PhantomData; use std::mem::{forget, transmute}; diff --git a/components/style/matching.rs b/components/style/matching.rs index 95742c68f4a..31ba54a37e0 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -371,7 +371,7 @@ trait PrivateMatchMethods: TElement { // since we have no way to know whether the decendants // need to be traversed at the beginning of the animation-only // restyle). - let task = ::context::SequentialTask::process_post_animation( + let task = crate::context::SequentialTask::process_post_animation( *self, PostAnimationTasks::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL, ); @@ -464,8 +464,11 @@ trait PrivateMatchMethods: TElement { } if !tasks.is_empty() { - let task = - ::context::SequentialTask::update_animations(*self, before_change_style, tasks); + let task = crate::context::SequentialTask::update_animations( + *self, + before_change_style, + tasks, + ); context.thread_local.tasks.push(task); } } diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index f0c9c7cad78..304f026deda 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -35,7 +35,7 @@ use void::{self, Void}; #[allow(non_upper_case_globals)] impl From for TransitionProperty { fn from(property: nsCSSPropertyID) -> TransitionProperty { - use properties::ShorthandId; + use crate::properties::ShorthandId; match property { % for prop in data.longhands: ${prop.nscsspropertyid()} => { diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 8c6dde8c738..61b8148bb65 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -87,7 +87,7 @@ macro_rules! computed_length_percentage_or_auto { /// Returns true if the computed value is absolute 0 or 0%. #[inline] pub fn is_definitely_zero(&self) -> bool { - use values::generics::length::LengthPercentageOrAuto::*; + use crate::values::generics::length::LengthPercentageOrAuto::*; match *self { LengthPercentage(ref l) => l.is_definitely_zero(), Auto => false, @@ -102,7 +102,7 @@ pub type LengthPercentageOrAuto = generics::GenericLengthPercentageOrAuto Self { - use values::generics::length::LengthPercentageOrAuto::*; + use crate::values::generics::length::LengthPercentageOrAuto::*; match self { LengthPercentage(l) => LengthPercentage(l.clamp_to_non_negative()), Auto => Auto, @@ -111,7 +111,7 @@ impl LengthPercentageOrAuto { /// Convert to have a borrow inside the enum pub fn as_ref(&self) -> generics::GenericLengthPercentageOrAuto<&LengthPercentage> { - use values::generics::length::LengthPercentageOrAuto::*; + use crate::values::generics::length::LengthPercentageOrAuto::*; match *self { LengthPercentage(ref lp) => LengthPercentage(lp), Auto => Auto, @@ -125,7 +125,7 @@ impl generics::GenericLengthPercentageOrAuto<&LengthPercentage> { /// Resolves the percentage. #[inline] pub fn percentage_relative_to(&self, basis: Length) -> LengthOrAuto { - use values::generics::length::LengthPercentageOrAuto::*; + use crate::values::generics::length::LengthPercentageOrAuto::*; match self { LengthPercentage(length_percentage) => { LengthPercentage(length_percentage.percentage_relative_to(basis)) @@ -137,7 +137,7 @@ impl generics::GenericLengthPercentageOrAuto<&LengthPercentage> { /// Maybe resolves the percentage. #[inline] pub fn maybe_percentage_relative_to(&self, basis: Option) -> LengthOrAuto { - use values::generics::length::LengthPercentageOrAuto::*; + use crate::values::generics::length::LengthPercentageOrAuto::*; match self { LengthPercentage(length_percentage) => length_percentage .maybe_percentage_relative_to(basis) diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index 42d541dc6f2..fba1f3f3c78 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -7,13 +7,13 @@ //! [images]: https://drafts.csswg.org/css-images/#image-values use crate::custom_properties; +use crate::values::generics::position::PositionComponent; use crate::values::serialize_atom_identifier; use crate::Atom; use crate::Zero; use servo_arc::Arc; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::generics::position::PositionComponent; /// An ` | none` value. /// diff --git a/components/style/values/generics/ui.rs b/components/style/values/generics/ui.rs index 6dfbb4a9c94..04c2951c70b 100644 --- a/components/style/values/generics/ui.rs +++ b/components/style/values/generics/ui.rs @@ -4,9 +4,9 @@ //! Generic values for UI properties. +use crate::values::specified::ui::CursorKind; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -use values::specified::ui::CursorKind; /// A generic value for the `cursor` property. ///