Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare stylo crates for switching to the 2018 edition #22083

Merged
merged 5 commits into from Nov 10, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use 2018-style paths in code generated by Mako

  • Loading branch information
SimonSapin committed Nov 10, 2018
commit e1fcffb336d763d851f14fae5cda464209552bb2
@@ -156,7 +156,7 @@ impl PseudoElement {
/// Construct a `CSSPseudoElementType` from a pseudo-element
#[inline]
fn pseudo_type(&self) -> CSSPseudoElementType {
use gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox;
use crate::gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox;

match *self {
% for pseudo in PSEUDOS:
@@ -270,12 +270,12 @@ def may_be_disabled_in(self, shorthand, product):

def base_type(self):
if self.predefined_type and not self.is_vector:
return "::values::specified::{}".format(self.predefined_type)
return "crate::values::specified::{}".format(self.predefined_type)
return "longhands::{}::SpecifiedValue".format(self.ident)

def specified_type(self):
if self.predefined_type and not self.is_vector:
ty = "::values::specified::{}".format(self.predefined_type)
ty = "crate::values::specified::{}".format(self.predefined_type)
else:
ty = "longhands::{}::SpecifiedValue".format(self.ident)
if self.boxed:

Large diffs are not rendered by default.

@@ -17,15 +17,15 @@
#[allow(unused_imports)]
use cssparser::{Color as CSSParserColor, RGBA};
#[allow(unused_imports)]
use values::specified::AllowQuirks;
use crate::values::specified::AllowQuirks;
#[allow(unused_imports)]
use smallvec::SmallVec;
pub use values::specified::${type} as SpecifiedValue;
pub use crate::values::specified::${type} as SpecifiedValue;
pub mod computed_value {
% if computed_type:
pub use ${computed_type} as T;
% else:
pub use values::computed::${type} as T;
pub use crate::values::computed::${type} as T;
% endif
}
% if initial_value:
@@ -91,19 +91,19 @@
#[allow(unused_imports)]
use cssparser::{Parser, BasicParseError};
#[allow(unused_imports)]
use parser::{Parse, ParserContext};
use crate::parser::{Parse, ParserContext};
#[allow(unused_imports)]
use properties::ShorthandId;
use crate::properties::ShorthandId;
#[allow(unused_imports)]
use selectors::parser::SelectorParseErrorKind;
#[allow(unused_imports)]
use style_traits::{ParseError, StyleParseErrorKind};
#[allow(unused_imports)]
use values::computed::{Context, ToComputedValue};
use crate::values::computed::{Context, ToComputedValue};
#[allow(unused_imports)]
use values::{computed, specified};
use crate::values::{computed, specified};
#[allow(unused_imports)]
use values::{Auto, Either, None_, Normal};
use crate::values::{Auto, Either, None_, Normal};
${caller.body()}
}

@@ -116,7 +116,7 @@
% else:
use smallvec::{IntoIter, SmallVec};
% endif
use values::computed::ComputedVecIter;
use crate::values::computed::ComputedVecIter;

/// The generic type defining the value for this property.
///
@@ -148,9 +148,9 @@
Sorry, this is stupid but needed for now.
% endif

use properties::animated_properties::ListAnimation;
use values::animated::{Animate, ToAnimatedValue, ToAnimatedZero, Procedure};
use values::distance::{SquaredDistance, ComputeSquaredDistance};
use crate::properties::animated_properties::ListAnimation;
use crate::values::animated::{Animate, ToAnimatedValue, ToAnimatedZero, Procedure};
use crate::values::distance::{SquaredDistance, ComputeSquaredDistance};

// FIXME(emilio): For some reason rust thinks that this alias is
// unused, even though it's clearly used below?
@@ -235,7 +235,7 @@
}
% endif

::style_traits::${separator}::parse(input, |parser| {
style_traits::${separator}::parse(input, |parser| {
single_value::parse(context, parser)
}).map(SpecifiedValue)
}
@@ -279,33 +279,33 @@
#[allow(unused_imports)]
use cssparser::{Parser, BasicParseError, Token};
#[allow(unused_imports)]
use parser::{Parse, ParserContext};
use crate::parser::{Parse, ParserContext};
#[allow(unused_imports)]
use properties::{UnparsedValue, ShorthandId};
use crate::properties::{UnparsedValue, ShorthandId};
#[allow(unused_imports)]
use values::{Auto, Either, None_, Normal};
use crate::values::{Auto, Either, None_, Normal};
#[allow(unused_imports)]
use error_reporting::ParseErrorReporter;
use crate::error_reporting::ParseErrorReporter;
#[allow(unused_imports)]
use properties::longhands;
use crate::properties::longhands;
#[allow(unused_imports)]
use properties::{LonghandId, LonghandIdSet};
use crate::properties::{LonghandId, LonghandIdSet};
#[allow(unused_imports)]
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
use crate::properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
#[allow(unused_imports)]
use properties::style_structs;
use crate::properties::style_structs;
#[allow(unused_imports)]
use selectors::parser::SelectorParseErrorKind;
#[allow(unused_imports)]
use servo_arc::Arc;
#[allow(unused_imports)]
use style_traits::{ParseError, StyleParseErrorKind};
#[allow(unused_imports)]
use values::computed::{Context, ToComputedValue};
use crate::values::computed::{Context, ToComputedValue};
#[allow(unused_imports)]
use values::{computed, generics, specified};
use crate::values::{computed, generics, specified};
#[allow(unused_imports)]
use Atom;
use crate::Atom;
${caller.body()}
#[allow(unused_variables)]
pub fn cascade_property(
@@ -428,7 +428,7 @@
keyword = keyword=Keyword(name, values, **keyword_kwargs)
%>
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
use properties::longhands::system_font::SystemFont;
use crate::properties::longhands::system_font::SystemFont;

pub mod computed_value {
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
@@ -511,7 +511,7 @@
///
/// Intended for use with presentation attributes, not style structs
pub fn from_gecko_keyword(kw: u32) -> Self {
use gecko_bindings::structs;
use crate::gecko_bindings::structs;
% for value in values:
// We can't match on enum values if we're matching on a u32
const ${to_rust_ident(value).upper()}: ${const_type}
@@ -535,7 +535,7 @@
/// Intended for use with presentation attributes, not style structs
pub fn from_gecko_keyword(kw: ${kw_type}) -> Self {
% for gecko_bit in bit_map.values():
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
use crate::gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
% endfor

let mut bits = ${type}::empty();
@@ -549,7 +549,7 @@

pub fn to_gecko_keyword(self) -> ${kw_type} {
% for gecko_bit in bit_map.values():
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
use crate::gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
% endfor

let mut bits: ${kw_type} = 0;
@@ -668,8 +668,8 @@
/// ${shorthand.spec}
pub mod ${shorthand.ident} {
use cssparser::Parser;
use parser::ParserContext;
use properties::{PropertyDeclaration, SourcePropertyDeclaration, MaybeBoxed, longhands};
use crate::parser::ParserContext;
use crate::properties::{PropertyDeclaration, SourcePropertyDeclaration, MaybeBoxed, longhands};
#[allow(unused_imports)]
use selectors::parser::SelectorParseErrorKind;
#[allow(unused_imports)]
@@ -772,7 +772,7 @@
input: &mut Parser<'i, 't>,
) -> Result<(), ParseError<'i>> {
#[allow(unused_imports)]
use properties::{NonCustomPropertyId, LonghandId};
use crate::properties::{NonCustomPropertyId, LonghandId};
input.parse_entirely(|input| parse_value(context, input)).map(|longhands| {
% for sub_property in shorthand.sub_properties:
% if sub_property.may_be_disabled_in(shorthand, product):
@@ -798,9 +798,9 @@
<% sub_properties=' '.join(sub_property_pattern % side for side in PHYSICAL_SIDES) %>
<%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)">
#[allow(unused_imports)]
use parser::Parse;
use values::generics::rect::Rect;
use values::specified;
use crate::parser::Parse;
use crate::values::generics::rect::Rect;
use crate::values::specified;

pub fn parse_value<'i, 't>(
context: &ParserContext,
@@ -852,7 +852,7 @@
return to_rust_ident(name.replace(side, phy_side).replace("inset-", ""))
%>
% if side is not None:
use logical_geometry::PhysicalSide;
use crate::logical_geometry::PhysicalSide;
match wm.${to_rust_ident(side)}_physical_side() {
% for phy_side in PHYSICAL_SIDES:
PhysicalSide::${phy_side.title()} => {
@@ -9,40 +9,40 @@
from itertools import groupby
%>

#[cfg(feature = "gecko")] use gecko_bindings::structs::RawServoAnimationValueMap;
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
#[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
#[cfg(feature = "gecko")] use crate::gecko_bindings::structs::RawServoAnimationValueMap;
#[cfg(feature = "gecko")] use crate::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
#[cfg(feature = "gecko")] use crate::gecko_bindings::structs::nsCSSPropertyID;
#[cfg(feature = "gecko")] use crate::gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
use itertools::{EitherOrBoth, Itertools};
use num_traits::Zero;
use properties::{CSSWideKeyword, PropertyDeclaration};
use properties::longhands;
use properties::longhands::visibility::computed_value::T as Visibility;
use properties::LonghandId;
use crate::properties::{CSSWideKeyword, PropertyDeclaration};
use crate::properties::longhands;
use crate::properties::longhands::visibility::computed_value::T as Visibility;
use crate::properties::LonghandId;
use servo_arc::Arc;
use smallvec::SmallVec;
use std::{cmp, ptr};
use std::mem::{self, ManuallyDrop};
use hash::FxHashMap;
use crate::hash::FxHashMap;
use super::ComputedValues;
use values::CSSFloat;
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
use values::animated::effects::Filter as AnimatedFilter;
#[cfg(feature = "gecko")] use values::computed::TransitionProperty;
use values::computed::Angle;
use values::computed::{ClipRect, Context};
use values::computed::{Length, LengthOrPercentage};
use values::computed::{Number, Percentage};
use values::computed::ToComputedValue;
use values::computed::transform::{DirectionVector, Matrix, Matrix3D};
use values::computed::transform::TransformOperation as ComputedTransformOperation;
use values::computed::transform::Transform as ComputedTransform;
use values::computed::transform::Rotate as ComputedRotate;
use values::computed::transform::Translate as ComputedTranslate;
use values::computed::transform::Scale as ComputedScale;
use values::generics::transform::{self, Rotate, Translate, Scale, Transform, TransformOperation};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::effects::Filter;
use crate::values::CSSFloat;
use crate::values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
use crate::values::animated::effects::Filter as AnimatedFilter;
#[cfg(feature = "gecko")] use crate::values::computed::TransitionProperty;
use crate::values::computed::Angle;
use crate::values::computed::{ClipRect, Context};
use crate::values::computed::{Length, LengthOrPercentage};
use crate::values::computed::{Number, Percentage};
use crate::values::computed::ToComputedValue;
use crate::values::computed::transform::{DirectionVector, Matrix, Matrix3D};
use crate::values::computed::transform::TransformOperation as ComputedTransformOperation;
use crate::values::computed::transform::Transform as ComputedTransform;
use crate::values::computed::transform::Rotate as ComputedRotate;
use crate::values::computed::transform::Translate as ComputedTranslate;
use crate::values::computed::transform::Scale as ComputedScale;
use crate::values::generics::transform::{self, Rotate, Translate, Scale, Transform, TransformOperation};
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
use crate::values::generics::effects::Filter;
use void::{self, Void};

/// Convert nsCSSPropertyID to TransitionProperty
@@ -357,7 +357,7 @@ impl AnimationValue {
/// "Uncompute" this animation value in order to be used inside the CSS
/// cascade.
pub fn uncompute(&self) -> PropertyDeclaration {
use properties::longhands;
use crate::properties::longhands;
use self::AnimationValue::*;

use super::PropertyDeclarationVariantRepr;
@@ -401,7 +401,7 @@ impl AnimationValue {
pub fn from_declaration(
decl: &PropertyDeclaration,
context: &mut Context,
extra_custom_properties: Option<<&Arc<::custom_properties::CustomPropertiesMap>>,
extra_custom_properties: Option<<&Arc<crate::custom_properties::CustomPropertiesMap>>,
initial: &ComputedValues
) -> Option<Self> {
use super::PropertyDeclarationVariantRepr;
@@ -815,7 +815,7 @@ impl ToAnimatedZero for Visibility {
impl Animate for ClipRect {
#[inline]
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
use values::computed::Length;
use crate::values::computed::Length;
let animate_component = |this: &Option<Length>, other: &Option<Length>| {
match (this.animate(other, procedure)?, procedure) {
(None, Procedure::Interpolate { .. }) => Ok(None),
@@ -1070,8 +1070,8 @@ impl Animate for ComputedTransformOperation {
&TransformOperation::Perspective(ref fd),
&TransformOperation::Perspective(ref td),
) => {
use values::computed::CSSPixelLength;
use values::generics::transform::create_perspective_matrix;
use crate::values::computed::CSSPixelLength;
use crate::values::generics::transform::create_perspective_matrix;

// From https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions:
//
@@ -1246,7 +1246,7 @@ impl ComputeSquaredDistance for MatrixDecomposed2D {
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
// Use Radian to compute the distance.
const RAD_PER_DEG: f64 = ::std::f64::consts::PI / 180.0;
const RAD_PER_DEG: f64 = std::f64::consts::PI / 180.0;
let angle1 = self.angle as f64 * RAD_PER_DEG;
let angle2 = other.angle as f64 * RAD_PER_DEG;
Ok(self.translate.compute_squared_distance(&other.translate)? +
@@ -48,8 +48,8 @@
${helpers.predefined_type(
"border-%s-width" % side_name,
"BorderSideWidth",
"::values::computed::NonNegativeLength::new(3.)",
computed_type="::values::computed::NonNegativeLength",
"crate::values::computed::NonNegativeLength::new(3.)",
computed_type="crate::values::computed::NonNegativeLength",
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"),
spec=maybe_logical_spec(side, "width"),
animation_value_type="NonNegativeLength",
@@ -64,7 +64,7 @@
${helpers.gecko_keyword_conversion(
Keyword('border-style',
"none solid double dotted dashed hidden groove ridge inset outset"),
type="::values::specified::BorderStyle",
type="crate::values::specified::BorderStyle",
)}

// FIXME(#4126): when gfx supports painting it, make this Size2D<LengthOrPercentage>
@@ -160,11 +160,11 @@ ${helpers.predefined_type(
)}

#[cfg(feature = "gecko")]
impl ::values::computed::BorderImageWidth {
pub fn to_gecko_rect(&self, sides: &mut ::gecko_bindings::structs::nsStyleSides) {
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use gecko::values::GeckoStyleCoordConvertible;
use values::generics::border::BorderImageSideWidth;
impl crate::values::computed::BorderImageWidth {
pub fn to_gecko_rect(&self, sides: &mut crate::gecko_bindings::structs::nsStyleSides) {
use crate::gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use crate::gecko::values::GeckoStyleCoordConvertible;
use crate::values::generics::border::BorderImageSideWidth;

% for i in range(0, 4):
match self.${i} {
@@ -182,16 +182,16 @@ impl ::values::computed::BorderImageWidth {
}

pub fn from_gecko_rect(
sides: &::gecko_bindings::structs::nsStyleSides,
) -> Option<::values::computed::BorderImageWidth> {
use gecko_bindings::structs::nsStyleUnit::{eStyleUnit_Factor, eStyleUnit_Auto};
use gecko_bindings::sugar::ns_style_coord::CoordData;
use gecko::values::GeckoStyleCoordConvertible;
use values::computed::{LengthOrPercentage, Number};
use values::generics::border::BorderImageSideWidth;
sides: &crate::gecko_bindings::structs::nsStyleSides,
) -> Option<crate::values::computed::BorderImageWidth> {
use crate::gecko_bindings::structs::nsStyleUnit::{eStyleUnit_Factor, eStyleUnit_Auto};
use crate::gecko_bindings::sugar::ns_style_coord::CoordData;
use crate::gecko::values::GeckoStyleCoordConvertible;
use crate::values::computed::{LengthOrPercentage, Number};
use crate::values::generics::border::BorderImageSideWidth;

Some(
::values::computed::BorderImageWidth::new(
crate::values::computed::BorderImageWidth::new(
% for i in range(0, 4):
match sides.data_at(${i}).unit() {
eStyleUnit_Auto => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.