Skip to content

Commit

Permalink
style: Port the style crate to rust 2018.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Jun 18, 2020
1 parent 9b980e2 commit 8f215a8
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions components/style/Cargo.toml
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion components/style/build_gecko.rs
Expand Up @@ -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};",
Expand Down
2 changes: 1 addition & 1 deletion components/style/dom.rs
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko_bindings/sugar/ownership.rs
Expand Up @@ -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};
Expand Down
9 changes: 6 additions & 3 deletions components/style/matching.rs
Expand Up @@ -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,
);
Expand Down Expand Up @@ -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);
}
}
Expand Down
Expand Up @@ -35,7 +35,7 @@ use void::{self, Void};
#[allow(non_upper_case_globals)]
impl From<nsCSSPropertyID> for TransitionProperty {
fn from(property: nsCSSPropertyID) -> TransitionProperty {
use properties::ShorthandId;
use crate::properties::ShorthandId;
match property {
% for prop in data.longhands:
${prop.nscsspropertyid()} => {
Expand Down
10 changes: 5 additions & 5 deletions components/style/values/computed/length.rs
Expand Up @@ -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,
Expand All @@ -102,7 +102,7 @@ pub type LengthPercentageOrAuto = generics::GenericLengthPercentageOrAuto<Length
impl LengthPercentageOrAuto {
/// Clamps the value to a non-negative value.
pub fn clamp_to_non_negative(self) -> Self {
use values::generics::length::LengthPercentageOrAuto::*;
use crate::values::generics::length::LengthPercentageOrAuto::*;
match self {
LengthPercentage(l) => LengthPercentage(l.clamp_to_non_negative()),
Auto => Auto,
Expand All @@ -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,
Expand All @@ -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))
Expand All @@ -137,7 +137,7 @@ impl generics::GenericLengthPercentageOrAuto<&LengthPercentage> {
/// Maybe resolves the percentage.
#[inline]
pub fn maybe_percentage_relative_to(&self, basis: Option<Length>) -> LengthOrAuto {
use values::generics::length::LengthPercentageOrAuto::*;
use crate::values::generics::length::LengthPercentageOrAuto::*;
match self {
LengthPercentage(length_percentage) => length_percentage
.maybe_percentage_relative_to(basis)
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/generics/image.rs
Expand Up @@ -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 `<image> | none` value.
///
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/generics/ui.rs
Expand Up @@ -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.
///
Expand Down

0 comments on commit 8f215a8

Please sign in to comment.