Bug 1560777 - Rustfmt and fix tidy on recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-06-23 13:03:00 +02:00
Родитель ed31d80598
Коммит 9ed6555245
16 изменённых файлов: 78 добавлений и 57 удалений

Просмотреть файл

@ -110,10 +110,7 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
if parsed_part {
flags |= SelectorFlags::HAS_PART;
}
self.build_with_specificity_and_flags(SpecificityAndFlags {
specificity,
flags,
})
self.build_with_specificity_and_flags(SpecificityAndFlags { specificity, flags })
}
/// Builds with an explicit SpecificityAndFlags. This is separated from build() so
@ -208,9 +205,9 @@ bitflags! {
pub struct SpecificityAndFlags {
/// There are two free bits here, since we use ten bits for each specificity
/// 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.
pub (crate) flags: SelectorFlags,
pub(crate) flags: SelectorFlags,
}
impl SpecificityAndFlags {

Просмотреть файл

@ -751,7 +751,11 @@ impl<Impl: SelectorImpl> Selector<Impl> {
/// Creates a Selector from a vec of Components, specified in parse order. Used in tests.
#[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();
for component in vec.into_iter() {
if let Some(combinator) = component.as_combinator() {
@ -760,10 +764,7 @@ impl<Impl: SelectorImpl> Selector<Impl> {
builder.push_simple_selector(component);
}
}
let spec = SpecificityAndFlags {
specificity,
flags,
};
let spec = SpecificityAndFlags { specificity, flags };
Selector(builder.build_with_specificity_and_flags(spec))
}

Просмотреть файл

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

Просмотреть файл

@ -99,7 +99,7 @@ impl nsStyleImage {
fn set_gradient(&mut self, gradient: Box<Gradient>) {
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 => {
let gradient: &Gradient =
&**self.__bindgen_anon_1.mGradient.as_ref();
let gradient: &Gradient = &**self.__bindgen_anon_1.mGradient.as_ref();
Some(GenericImage::Gradient(Box::new(gradient.clone())))
},
nsStyleImageType::eStyleImageType_Element => {

Просмотреть файл

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

Просмотреть файл

@ -189,7 +189,7 @@ impl<'lr> TShadowRoot for GeckoShadowRoot<'lr> {
#[inline]
fn parts<'a>(&self) -> &[<Self::ConcreteNode as TNode>::ConcreteElement]
where
Self: 'a
Self: 'a,
{
let slice: &[*const RawGeckoElement] = &*self.0.mParts;
@ -1350,7 +1350,8 @@ impl<'le> TElement for GeckoElement<'le> {
#[inline]
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.

Просмотреть файл

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

Просмотреть файл

@ -298,8 +298,7 @@ impl MediaFeatureExpression {
#[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..];
requirements.insert(ParsingRequirements::WEBKIT_PREFIX);
if unsafe {

Просмотреть файл

@ -165,9 +165,11 @@ def parse_property_aliases(alias_list):
result.append((name, pref))
return result
def to_phys(name, logical, physical):
return name.replace(logical, physical).replace("inset-", "")
class Longhand(object):
def __init__(self, style_struct, name, spec=None, animation_value_type=None, keyword=None,
predefined_type=None, servo_pref=None, gecko_pref=None,
@ -247,7 +249,7 @@ class Longhand(object):
def all_physical_mapped_properties(self):
assert self.logical
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)
logical_side = candidates[0]

Просмотреть файл

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

Просмотреть файл

@ -258,7 +258,7 @@ impl SelectorMap<Rule> {
}
/// 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,
rules: &[Rule],
matching_rules: &mut ApplicableDeclarationList,

Просмотреть файл

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

Просмотреть файл

@ -15,7 +15,16 @@ use style_traits::{CssWriter, ToCss};
/// An <image> | <none> (for background-image, for example).
#[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> {
/// The `none` value.

Просмотреть файл

@ -11,10 +11,12 @@ use crate::custom_properties::SpecifiedValue;
use crate::parser::{Parse, ParserContext};
use crate::stylesheets::CorsMode;
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::specified::position::{Position, PositionComponent, Side};
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::{Angle, Color, Length, LengthPercentage};
use crate::values::specified::{Number, NumberOrPercentage, Percentage};
@ -250,7 +252,12 @@ impl Parse for Gradient {
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,
input: &mut Parser<'i, 't>,
) -> 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>>;
#[derive(Clone, Copy, Parse)]
@ -512,7 +521,9 @@ impl GradientKind {
d
} else {
match *compat_mode {
GradientCompatMode::Modern => LineDirection::Vertical(VerticalPositionKeyword::Bottom),
GradientCompatMode::Modern => {
LineDirection::Vertical(VerticalPositionKeyword::Bottom)
},
_ => LineDirection::Vertical(VerticalPositionKeyword::Top),
}
};
@ -563,10 +574,10 @@ impl generic::LineDirection for LineDirection {
LineDirection::Angle(ref angle) => angle.degrees() == 180.0,
LineDirection::Vertical(VerticalPositionKeyword::Bottom) => {
compat_mode == GradientCompatMode::Modern
}
},
LineDirection::Vertical(VerticalPositionKeyword::Top) => {
compat_mode != GradientCompatMode::Modern
}
},
_ => false,
}
}
@ -621,7 +632,9 @@ impl LineDirection {
// Fall back to Modern compatibility mode in case there is a `to` keyword.
// According to Gecko, `-moz-linear-gradient(to ...)` should serialize like
// `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,
// parsing should throw an error.
GradientCompatMode::WebKit if to_ident.is_ok() => {
@ -741,7 +754,9 @@ impl ShapeExtent {
compat_mode: GradientCompatMode,
) -> Result<Self, ParseError<'i>> {
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))
},
ShapeExtent::Contain => Ok(ShapeExtent::ClosestSide),

Просмотреть файл

@ -7,15 +7,15 @@
//!
//! [position]: https://drafts.csswg.org/css-backgrounds-3/#position
use crate::Atom;
use crate::selector_map::PrecomputedHashMap;
use crate::parser::{Parse, ParserContext};
use crate::selector_map::PrecomputedHashMap;
use crate::str::HTML_SPACE_CHARACTERS;
use crate::values::computed::LengthPercentage as ComputedLengthPercentage;
use crate::values::computed::{Context, Percentage, ToComputedValue};
use crate::values::generics::position::Position as GenericPosition;
use crate::values::generics::position::ZIndex as GenericZIndex;
use crate::values::specified::{AllowQuirks, Integer, LengthPercentage};
use crate::Atom;
use crate::Zero;
use cssparser::Parser;
use selectors::parser::SelectorParseErrorKind;
@ -579,7 +579,9 @@ impl Parse for TemplateAreas {
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
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);
}

Просмотреть файл

@ -9,7 +9,9 @@ use crate::values::computed::{Context, LengthPercentage as ComputedLengthPercent
use crate::values::computed::{Percentage as ComputedPercentage, ToComputedValue};
use crate::values::generics::transform as generic;
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::Zero;
use cssparser::Parser;