style: Port the style crate to rust 2018.

Differential Revision: https://phabricator.services.mozilla.com/D80101
This commit is contained in:
Emilio Cobos Álvarez 2020-06-17 23:40:30 +00:00
parent 9b980e2f49
commit 8f215a8444
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
9 changed files with 18 additions and 14 deletions

View file

@ -6,6 +6,7 @@ license = "MPL-2.0"
publish = false publish = false
build = "build.rs" build = "build.rs"
edition = "2018"
# https://github.com/rust-lang/cargo/issues/3544 # https://github.com/rust-lang/cargo/issues/3544
links = "servo_style_crate" links = "servo_style_crate"

View file

@ -318,7 +318,7 @@ fn generate_structs() {
fixups.push(Fixup { fixups.push(Fixup {
pat: format!("\\broot\\s*::\\s*{}\\b", gecko), 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!( builder.blacklist_type(gecko).raw_line(format!(
"pub type {0}{2} = {1}{2};", "pub type {0}{2} = {1}{2};",

View file

@ -816,7 +816,7 @@ pub trait TElement:
Self: 'a, Self: 'a,
F: FnMut(&'a CascadeData, Self), 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(); let target = self.rule_hash_target();
if !target.matches_user_and_author_rules() { if !target.matches_user_and_author_rules() {

View file

@ -4,7 +4,7 @@
//! Helpers for different FFI pointer kinds that Gecko's FFI layer uses. //! 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 servo_arc::{Arc, RawOffsetArc};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem::{forget, transmute}; use std::mem::{forget, transmute};

View file

@ -371,7 +371,7 @@ trait PrivateMatchMethods: TElement {
// since we have no way to know whether the decendants // since we have no way to know whether the decendants
// need to be traversed at the beginning of the animation-only // need to be traversed at the beginning of the animation-only
// restyle). // restyle).
let task = ::context::SequentialTask::process_post_animation( let task = crate::context::SequentialTask::process_post_animation(
*self, *self,
PostAnimationTasks::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL, PostAnimationTasks::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL,
); );
@ -464,8 +464,11 @@ trait PrivateMatchMethods: TElement {
} }
if !tasks.is_empty() { if !tasks.is_empty() {
let task = let task = crate::context::SequentialTask::update_animations(
::context::SequentialTask::update_animations(*self, before_change_style, tasks); *self,
before_change_style,
tasks,
);
context.thread_local.tasks.push(task); context.thread_local.tasks.push(task);
} }
} }

View file

@ -35,7 +35,7 @@ use void::{self, Void};
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
impl From<nsCSSPropertyID> for TransitionProperty { impl From<nsCSSPropertyID> for TransitionProperty {
fn from(property: nsCSSPropertyID) -> TransitionProperty { fn from(property: nsCSSPropertyID) -> TransitionProperty {
use properties::ShorthandId; use crate::properties::ShorthandId;
match property { match property {
% for prop in data.longhands: % for prop in data.longhands:
${prop.nscsspropertyid()} => { ${prop.nscsspropertyid()} => {

View file

@ -87,7 +87,7 @@ macro_rules! computed_length_percentage_or_auto {
/// Returns true if the computed value is absolute 0 or 0%. /// Returns true if the computed value is absolute 0 or 0%.
#[inline] #[inline]
pub fn is_definitely_zero(&self) -> bool { pub fn is_definitely_zero(&self) -> bool {
use values::generics::length::LengthPercentageOrAuto::*; use crate::values::generics::length::LengthPercentageOrAuto::*;
match *self { match *self {
LengthPercentage(ref l) => l.is_definitely_zero(), LengthPercentage(ref l) => l.is_definitely_zero(),
Auto => false, Auto => false,
@ -102,7 +102,7 @@ pub type LengthPercentageOrAuto = generics::GenericLengthPercentageOrAuto<Length
impl LengthPercentageOrAuto { impl LengthPercentageOrAuto {
/// Clamps the value to a non-negative value. /// Clamps the value to a non-negative value.
pub fn clamp_to_non_negative(self) -> Self { pub fn clamp_to_non_negative(self) -> Self {
use values::generics::length::LengthPercentageOrAuto::*; use crate::values::generics::length::LengthPercentageOrAuto::*;
match self { match self {
LengthPercentage(l) => LengthPercentage(l.clamp_to_non_negative()), LengthPercentage(l) => LengthPercentage(l.clamp_to_non_negative()),
Auto => Auto, Auto => Auto,
@ -111,7 +111,7 @@ impl LengthPercentageOrAuto {
/// Convert to have a borrow inside the enum /// Convert to have a borrow inside the enum
pub fn as_ref(&self) -> generics::GenericLengthPercentageOrAuto<&LengthPercentage> { pub fn as_ref(&self) -> generics::GenericLengthPercentageOrAuto<&LengthPercentage> {
use values::generics::length::LengthPercentageOrAuto::*; use crate::values::generics::length::LengthPercentageOrAuto::*;
match *self { match *self {
LengthPercentage(ref lp) => LengthPercentage(lp), LengthPercentage(ref lp) => LengthPercentage(lp),
Auto => Auto, Auto => Auto,
@ -125,7 +125,7 @@ impl generics::GenericLengthPercentageOrAuto<&LengthPercentage> {
/// Resolves the percentage. /// Resolves the percentage.
#[inline] #[inline]
pub fn percentage_relative_to(&self, basis: Length) -> LengthOrAuto { pub fn percentage_relative_to(&self, basis: Length) -> LengthOrAuto {
use values::generics::length::LengthPercentageOrAuto::*; use crate::values::generics::length::LengthPercentageOrAuto::*;
match self { match self {
LengthPercentage(length_percentage) => { LengthPercentage(length_percentage) => {
LengthPercentage(length_percentage.percentage_relative_to(basis)) LengthPercentage(length_percentage.percentage_relative_to(basis))
@ -137,7 +137,7 @@ impl generics::GenericLengthPercentageOrAuto<&LengthPercentage> {
/// Maybe resolves the percentage. /// Maybe resolves the percentage.
#[inline] #[inline]
pub fn maybe_percentage_relative_to(&self, basis: Option<Length>) -> LengthOrAuto { pub fn maybe_percentage_relative_to(&self, basis: Option<Length>) -> LengthOrAuto {
use values::generics::length::LengthPercentageOrAuto::*; use crate::values::generics::length::LengthPercentageOrAuto::*;
match self { match self {
LengthPercentage(length_percentage) => length_percentage LengthPercentage(length_percentage) => length_percentage
.maybe_percentage_relative_to(basis) .maybe_percentage_relative_to(basis)

View file

@ -7,13 +7,13 @@
//! [images]: https://drafts.csswg.org/css-images/#image-values //! [images]: https://drafts.csswg.org/css-images/#image-values
use crate::custom_properties; use crate::custom_properties;
use crate::values::generics::position::PositionComponent;
use crate::values::serialize_atom_identifier; use crate::values::serialize_atom_identifier;
use crate::Atom; use crate::Atom;
use crate::Zero; use crate::Zero;
use servo_arc::Arc; use servo_arc::Arc;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss}; use style_traits::{CssWriter, ToCss};
use values::generics::position::PositionComponent;
/// An `<image> | none` value. /// An `<image> | none` value.
/// ///

View file

@ -4,9 +4,9 @@
//! Generic values for UI properties. //! Generic values for UI properties.
use crate::values::specified::ui::CursorKind;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss}; use style_traits::{CssWriter, ToCss};
use values::specified::ui::CursorKind;
/// A generic value for the `cursor` property. /// A generic value for the `cursor` property.
/// ///