Rustfmt and fix tidy on recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-06-23 13:03:00 +02:00
parent 6eedebe2c8
commit ed2e9ce482
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
16 changed files with 78 additions and 57 deletions

View file

@ -110,10 +110,7 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
if parsed_part { if parsed_part {
flags |= SelectorFlags::HAS_PART; flags |= SelectorFlags::HAS_PART;
} }
self.build_with_specificity_and_flags(SpecificityAndFlags { self.build_with_specificity_and_flags(SpecificityAndFlags { specificity, flags })
specificity,
flags,
})
} }
/// Builds with an explicit SpecificityAndFlags. This is separated from build() so /// Builds with an explicit SpecificityAndFlags. This is separated from build() so
@ -208,9 +205,9 @@ bitflags! {
pub struct SpecificityAndFlags { pub struct SpecificityAndFlags {
/// There are two free bits here, since we use ten bits for each specificity /// There are two free bits here, since we use ten bits for each specificity
/// kind (id, class, element). /// kind (id, class, element).
pub (crate) specificity: u32, pub(crate) specificity: u32,
/// There's padding after this field due to the size of the flags. /// There's padding after this field due to the size of the flags.
pub (crate) flags: SelectorFlags, pub(crate) flags: SelectorFlags,
} }
impl SpecificityAndFlags { impl SpecificityAndFlags {

View file

@ -751,7 +751,11 @@ impl<Impl: SelectorImpl> Selector<Impl> {
/// Creates a Selector from a vec of Components, specified in parse order. Used in tests. /// Creates a Selector from a vec of Components, specified in parse order. Used in tests.
#[allow(unused)] #[allow(unused)]
pub (crate) fn from_vec(vec: Vec<Component<Impl>>, specificity: u32, flags: SelectorFlags) -> Self { pub(crate) fn from_vec(
vec: Vec<Component<Impl>>,
specificity: u32,
flags: SelectorFlags,
) -> Self {
let mut builder = SelectorBuilder::default(); let mut builder = SelectorBuilder::default();
for component in vec.into_iter() { for component in vec.into_iter() {
if let Some(combinator) = component.as_combinator() { if let Some(combinator) = component.as_combinator() {
@ -760,10 +764,7 @@ impl<Impl: SelectorImpl> Selector<Impl> {
builder.push_simple_selector(component); builder.push_simple_selector(component);
} }
} }
let spec = SpecificityAndFlags { let spec = SpecificityAndFlags { specificity, flags };
specificity,
flags,
};
Selector(builder.build_with_specificity_and_flags(spec)) Selector(builder.build_with_specificity_and_flags(spec))
} }

View file

@ -349,7 +349,7 @@ pub trait TShadowRoot: Sized + Copy + Clone + PartialEq {
/// Get the list of shadow parts for this shadow root. /// Get the list of shadow parts for this shadow root.
fn parts<'a>(&self) -> &[<Self::ConcreteNode as TNode>::ConcreteElement] fn parts<'a>(&self) -> &[<Self::ConcreteNode as TNode>::ConcreteElement]
where where
Self: 'a Self: 'a,
{ {
&[] &[]
} }
@ -534,7 +534,7 @@ pub trait TElement:
/// Internal iterator for the part names of this element. /// Internal iterator for the part names of this element.
fn each_part<F>(&self, _callback: F) fn each_part<F>(&self, _callback: F)
where where
F: FnMut(&Atom) F: FnMut(&Atom),
{ {
} }

View file

@ -99,7 +99,7 @@ impl nsStyleImage {
fn set_gradient(&mut self, gradient: Box<Gradient>) { fn set_gradient(&mut self, gradient: Box<Gradient>) {
unsafe { unsafe {
bindings::Gecko_SetGradientImageValue(self, Box::into_raw(gradient)); bindings::Gecko_SetGradientImageValue(self, Box::into_raw(gradient));
} }
} }
@ -142,8 +142,7 @@ impl nsStyleImage {
} }
}, },
nsStyleImageType::eStyleImageType_Gradient => { nsStyleImageType::eStyleImageType_Gradient => {
let gradient: &Gradient = let gradient: &Gradient = &**self.__bindgen_anon_1.mGradient.as_ref();
&**self.__bindgen_anon_1.mGradient.as_ref();
Some(GenericImage::Gradient(Box::new(gradient.clone()))) Some(GenericImage::Gradient(Box::new(gradient.clone())))
}, },
nsStyleImageType::eStyleImageType_Element => { nsStyleImageType::eStyleImageType_Element => {

View file

@ -354,9 +354,8 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
#[inline] #[inline]
fn parse_part(&self) -> bool { fn parse_part(&self) -> bool {
self.chrome_rules_enabled() || unsafe { self.chrome_rules_enabled() ||
structs::StaticPrefs_sVarCache_layout_css_shadow_parts_enabled unsafe { structs::StaticPrefs_sVarCache_layout_css_shadow_parts_enabled }
}
} }
fn parse_non_ts_pseudo_class( fn parse_non_ts_pseudo_class(

View file

@ -189,7 +189,7 @@ impl<'lr> TShadowRoot for GeckoShadowRoot<'lr> {
#[inline] #[inline]
fn parts<'a>(&self) -> &[<Self::ConcreteNode as TNode>::ConcreteElement] fn parts<'a>(&self) -> &[<Self::ConcreteNode as TNode>::ConcreteElement]
where where
Self: 'a Self: 'a,
{ {
let slice: &[*const RawGeckoElement] = &*self.0.mParts; let slice: &[*const RawGeckoElement] = &*self.0.mParts;
@ -1350,7 +1350,8 @@ impl<'le> TElement for GeckoElement<'le> {
#[inline] #[inline]
fn has_part_attr(&self) -> bool { fn has_part_attr(&self) -> bool {
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasPart) self.as_node()
.get_bool_flag(nsINode_BooleanFlag::ElementHasPart)
} }
// FIXME(emilio): we should probably just return a reference to the Atom. // FIXME(emilio): we should probably just return a reference to the Atom.

View file

@ -78,7 +78,8 @@ pub struct DescendantInvalidationLists<'a> {
impl<'a> DescendantInvalidationLists<'a> { impl<'a> DescendantInvalidationLists<'a> {
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool {
self.dom_descendants.is_empty() && self.slotted_descendants.is_empty() && self.dom_descendants.is_empty() &&
self.slotted_descendants.is_empty() &&
self.parts.is_empty() self.parts.is_empty()
} }
} }
@ -179,9 +180,7 @@ impl<'a> Invalidation<'a> {
Combinator::Child | Combinator::Descendant | Combinator::PseudoElement => { Combinator::Child | Combinator::Descendant | Combinator::PseudoElement => {
InvalidationKind::Descendant(DescendantInvalidationKind::Dom) InvalidationKind::Descendant(DescendantInvalidationKind::Dom)
}, },
Combinator::Part => { Combinator::Part => InvalidationKind::Descendant(DescendantInvalidationKind::Part),
InvalidationKind::Descendant(DescendantInvalidationKind::Part)
},
Combinator::SlotAssignment => { Combinator::SlotAssignment => {
InvalidationKind::Descendant(DescendantInvalidationKind::Slotted) InvalidationKind::Descendant(DescendantInvalidationKind::Slotted)
}, },
@ -506,7 +505,6 @@ where
any any
} }
fn invalidate_slotted_elements(&mut self, invalidations: &[Invalidation<'b>]) -> bool { fn invalidate_slotted_elements(&mut self, invalidations: &[Invalidation<'b>]) -> bool {
if invalidations.is_empty() { if invalidations.is_empty() {
return false; return false;

View file

@ -298,8 +298,7 @@ impl MediaFeatureExpression {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {
if starts_with_ignore_ascii_case(feature_name, "-webkit-") if starts_with_ignore_ascii_case(feature_name, "-webkit-") {
{
feature_name = &feature_name[8..]; feature_name = &feature_name[8..];
requirements.insert(ParsingRequirements::WEBKIT_PREFIX); requirements.insert(ParsingRequirements::WEBKIT_PREFIX);
if unsafe { if unsafe {

View file

@ -165,9 +165,11 @@ def parse_property_aliases(alias_list):
result.append((name, pref)) result.append((name, pref))
return result return result
def to_phys(name, logical, physical): def to_phys(name, logical, physical):
return name.replace(logical, physical).replace("inset-", "") return name.replace(logical, physical).replace("inset-", "")
class Longhand(object): class Longhand(object):
def __init__(self, style_struct, name, spec=None, animation_value_type=None, keyword=None, def __init__(self, style_struct, name, spec=None, animation_value_type=None, keyword=None,
predefined_type=None, servo_pref=None, gecko_pref=None, predefined_type=None, servo_pref=None, gecko_pref=None,
@ -247,7 +249,7 @@ class Longhand(object):
def all_physical_mapped_properties(self): def all_physical_mapped_properties(self):
assert self.logical assert self.logical
candidates = [s for s in LOGICAL_SIDES + LOGICAL_SIZES + LOGICAL_CORNERS candidates = [s for s in LOGICAL_SIDES + LOGICAL_SIZES + LOGICAL_CORNERS
if s in self.name] + [s for s in LOGICAL_AXES if self.name.endswith(s)] if s in self.name] + [s for s in LOGICAL_AXES if self.name.endswith(s)]
assert(len(candidates) == 1) assert(len(candidates) == 1)
logical_side = candidates[0] logical_side = candidates[0]

View file

@ -332,17 +332,14 @@ where
let host = shadow.host(); let host = shadow.host();
let containing_shadow = host.containing_shadow(); let containing_shadow = host.containing_shadow();
let part_rules = match containing_shadow { let part_rules = match containing_shadow {
Some(shadow) => { Some(shadow) => shadow
shadow .style_data()
.style_data() .and_then(|data| data.part_rules(self.pseudo_element)),
.and_then(|data| data.part_rules(self.pseudo_element)) None => self
}, .stylist
None => { .cascade_data()
self.stylist .borrow_for_origin(Origin::Author)
.cascade_data() .part_rules(self.pseudo_element),
.borrow_for_origin(Origin::Author)
.part_rules(self.pseudo_element)
}
}; };
// TODO(emilio): SameTreeAuthorNormal is a bit of a lie here, we may // TODO(emilio): SameTreeAuthorNormal is a bit of a lie here, we may

View file

@ -258,7 +258,7 @@ impl SelectorMap<Rule> {
} }
/// Adds rules in `rules` that match `element` to the `matching_rules` list. /// Adds rules in `rules` that match `element` to the `matching_rules` list.
pub (crate) fn get_matching_rules<E, F>( pub(crate) fn get_matching_rules<E, F>(
element: E, element: E,
rules: &[Rule], rules: &[Rule],
matching_rules: &mut ApplicableDeclarationList, matching_rules: &mut ApplicableDeclarationList,

View file

@ -66,10 +66,10 @@ impl generic::LineDirection for LineDirection {
LineDirection::Angle(angle) => angle.radians() == PI, LineDirection::Angle(angle) => angle.radians() == PI,
LineDirection::Vertical(VerticalPositionKeyword::Bottom) => { LineDirection::Vertical(VerticalPositionKeyword::Bottom) => {
compat_mode == GradientCompatMode::Modern compat_mode == GradientCompatMode::Modern
} },
LineDirection::Vertical(VerticalPositionKeyword::Top) => { LineDirection::Vertical(VerticalPositionKeyword::Top) => {
compat_mode != GradientCompatMode::Modern compat_mode != GradientCompatMode::Modern
} },
_ => false, _ => false,
} }
} }

View file

@ -15,7 +15,16 @@ use style_traits::{CssWriter, ToCss};
/// An <image> | <none> (for background-image, for example). /// An <image> | <none> (for background-image, for example).
#[derive( #[derive(
Clone, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, Clone,
Debug,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] )]
pub enum GenericImageLayer<Image> { pub enum GenericImageLayer<Image> {
/// The `none` value. /// The `none` value.

View file

@ -11,10 +11,12 @@ use crate::custom_properties::SpecifiedValue;
use crate::parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
use crate::stylesheets::CorsMode; use crate::stylesheets::CorsMode;
use crate::values::generics::image::PaintWorklet; use crate::values::generics::image::PaintWorklet;
use crate::values::generics::image::{self as generic, Circle, GradientCompatMode, Ellipse, ShapeExtent}; use crate::values::generics::image::{
self as generic, Circle, Ellipse, GradientCompatMode, ShapeExtent,
};
use crate::values::generics::position::Position as GenericPosition; use crate::values::generics::position::Position as GenericPosition;
use crate::values::specified::position::{Position, PositionComponent, Side};
use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword}; use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword};
use crate::values::specified::position::{Position, PositionComponent, Side};
use crate::values::specified::url::SpecifiedImageUrl; use crate::values::specified::url::SpecifiedImageUrl;
use crate::values::specified::{Angle, Color, Length, LengthPercentage}; use crate::values::specified::{Angle, Color, Length, LengthPercentage};
use crate::values::specified::{Number, NumberOrPercentage, Percentage}; use crate::values::specified::{Number, NumberOrPercentage, Percentage};
@ -250,7 +252,12 @@ impl Parse for Gradient {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
} }
Ok(Gradient { items, repeating, kind, compat_mode }) Ok(Gradient {
items,
repeating,
kind,
compat_mode,
})
} }
} }
@ -259,7 +266,9 @@ impl Gradient {
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
use crate::values::specified::position::{HorizontalPositionKeyword as X, VerticalPositionKeyword as Y}; use crate::values::specified::position::{
HorizontalPositionKeyword as X, VerticalPositionKeyword as Y,
};
type Point = GenericPosition<Component<X>, Component<Y>>; type Point = GenericPosition<Component<X>, Component<Y>>;
#[derive(Clone, Copy, Parse)] #[derive(Clone, Copy, Parse)]
@ -512,7 +521,9 @@ impl GradientKind {
d d
} else { } else {
match *compat_mode { match *compat_mode {
GradientCompatMode::Modern => LineDirection::Vertical(VerticalPositionKeyword::Bottom), GradientCompatMode::Modern => {
LineDirection::Vertical(VerticalPositionKeyword::Bottom)
},
_ => LineDirection::Vertical(VerticalPositionKeyword::Top), _ => LineDirection::Vertical(VerticalPositionKeyword::Top),
} }
}; };
@ -563,10 +574,10 @@ impl generic::LineDirection for LineDirection {
LineDirection::Angle(ref angle) => angle.degrees() == 180.0, LineDirection::Angle(ref angle) => angle.degrees() == 180.0,
LineDirection::Vertical(VerticalPositionKeyword::Bottom) => { LineDirection::Vertical(VerticalPositionKeyword::Bottom) => {
compat_mode == GradientCompatMode::Modern compat_mode == GradientCompatMode::Modern
} },
LineDirection::Vertical(VerticalPositionKeyword::Top) => { LineDirection::Vertical(VerticalPositionKeyword::Top) => {
compat_mode != GradientCompatMode::Modern compat_mode != GradientCompatMode::Modern
} },
_ => false, _ => false,
} }
} }
@ -621,7 +632,9 @@ impl LineDirection {
// Fall back to Modern compatibility mode in case there is a `to` keyword. // Fall back to Modern compatibility mode in case there is a `to` keyword.
// According to Gecko, `-moz-linear-gradient(to ...)` should serialize like // According to Gecko, `-moz-linear-gradient(to ...)` should serialize like
// `linear-gradient(to ...)`. // `linear-gradient(to ...)`.
GradientCompatMode::Moz if to_ident.is_ok() => *compat_mode = GradientCompatMode::Modern, GradientCompatMode::Moz if to_ident.is_ok() => {
*compat_mode = GradientCompatMode::Modern
},
// There is no `to` keyword in webkit prefixed syntax. If it's consumed, // There is no `to` keyword in webkit prefixed syntax. If it's consumed,
// parsing should throw an error. // parsing should throw an error.
GradientCompatMode::WebKit if to_ident.is_ok() => { GradientCompatMode::WebKit if to_ident.is_ok() => {
@ -741,7 +754,9 @@ impl ShapeExtent {
compat_mode: GradientCompatMode, compat_mode: GradientCompatMode,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
match Self::parse(input)? { match Self::parse(input)? {
ShapeExtent::Contain | ShapeExtent::Cover if compat_mode == GradientCompatMode::Modern => { ShapeExtent::Contain | ShapeExtent::Cover
if compat_mode == GradientCompatMode::Modern =>
{
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}, },
ShapeExtent::Contain => Ok(ShapeExtent::ClosestSide), ShapeExtent::Contain => Ok(ShapeExtent::ClosestSide),

View file

@ -7,15 +7,15 @@
//! //!
//! [position]: https://drafts.csswg.org/css-backgrounds-3/#position //! [position]: https://drafts.csswg.org/css-backgrounds-3/#position
use crate::Atom;
use crate::selector_map::PrecomputedHashMap;
use crate::parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
use crate::selector_map::PrecomputedHashMap;
use crate::str::HTML_SPACE_CHARACTERS; use crate::str::HTML_SPACE_CHARACTERS;
use crate::values::computed::LengthPercentage as ComputedLengthPercentage; use crate::values::computed::LengthPercentage as ComputedLengthPercentage;
use crate::values::computed::{Context, Percentage, ToComputedValue}; use crate::values::computed::{Context, Percentage, ToComputedValue};
use crate::values::generics::position::Position as GenericPosition; use crate::values::generics::position::Position as GenericPosition;
use crate::values::generics::position::ZIndex as GenericZIndex; use crate::values::generics::position::ZIndex as GenericZIndex;
use crate::values::specified::{AllowQuirks, Integer, LengthPercentage}; use crate::values::specified::{AllowQuirks, Integer, LengthPercentage};
use crate::Atom;
use crate::Zero; use crate::Zero;
use cssparser::Parser; use cssparser::Parser;
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
@ -579,7 +579,9 @@ impl Parse for TemplateAreas {
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let mut strings = vec![]; let mut strings = vec![];
while let Ok(string) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into())) { while let Ok(string) =
input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned().into()))
{
strings.push(string); strings.push(string);
} }

View file

@ -9,7 +9,9 @@ use crate::values::computed::{Context, LengthPercentage as ComputedLengthPercent
use crate::values::computed::{Percentage as ComputedPercentage, ToComputedValue}; use crate::values::computed::{Percentage as ComputedPercentage, ToComputedValue};
use crate::values::generics::transform as generic; use crate::values::generics::transform as generic;
use crate::values::generics::transform::{Matrix, Matrix3D}; use crate::values::generics::transform::{Matrix, Matrix3D};
use crate::values::specified::position::{Side, HorizontalPositionKeyword, VerticalPositionKeyword}; use crate::values::specified::position::{
HorizontalPositionKeyword, Side, VerticalPositionKeyword,
};
use crate::values::specified::{self, Angle, Integer, Length, LengthPercentage, Number}; use crate::values::specified::{self, Angle, Integer, Length, LengthPercentage, Number};
use crate::Zero; use crate::Zero;
use cssparser::Parser; use cssparser::Parser;