author | Emilio Cobos Álvarez <emilio@crisal.io> |
Sun, 23 Jun 2019 13:03:00 +0200 | |
changeset 479891 | cce39206381e78106916c8232452f71e9dd86ad9 |
parent 479890 | c90edb8e903d224c775f541477d9170ace8471c9 |
child 479892 | 4ed761cebb7f768a44beebca0069fb3320a05018 |
push id | 36189 |
push user | cbrindusan@mozilla.com |
push date | Sun, 23 Jun 2019 21:47:52 +0000 |
treeherder | mozilla-central@303b1fcafdeb [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1560777 |
milestone | 69.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/servo/components/selectors/builder.rs +++ b/servo/components/selectors/builder.rs @@ -105,20 +105,17 @@ impl<Impl: SelectorImpl> SelectorBuilder flags |= SelectorFlags::HAS_PSEUDO; } if parsed_slotted { flags |= SelectorFlags::HAS_SLOTTED; } 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 /// that unit tests can pass an explicit specificity. #[inline(always)] pub fn build_with_specificity_and_flags( &mut self, spec: SpecificityAndFlags, @@ -203,19 +200,19 @@ bitflags! { const HAS_PART = 1 << 2; } } #[derive(Clone, Copy, Debug, Eq, PartialEq, ToShmem)] 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 { #[inline] pub fn specificity(&self) -> u32 { self.specificity }
--- a/servo/components/selectors/parser.rs +++ b/servo/components/selectors/parser.rs @@ -746,29 +746,30 @@ impl<Impl: SelectorImpl> Selector<Impl> /// `offset`. #[inline] pub fn iter_raw_parse_order_from(&self, offset: usize) -> Rev<slice::Iter<Component<Impl>>> { self.0.slice[..self.len() - offset].iter().rev() } /// 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() { builder.push_combinator(combinator); } else { builder.push_simple_selector(component); } } - let spec = SpecificityAndFlags { - specificity, - flags, - }; + let spec = SpecificityAndFlags { specificity, flags }; Selector(builder.build_with_specificity_and_flags(spec)) } /// Returns count of simple selectors and combinators in the Selector. #[inline] pub fn len(&self) -> usize { self.0.slice.len() }
--- a/servo/components/style/dom.rs +++ b/servo/components/style/dom.rs @@ -344,17 +344,17 @@ pub trait TShadowRoot: Sized + Copy + Cl /// Get the style data for this ShadowRoot. fn style_data<'a>(&self) -> Option<&'a CascadeData> where Self: 'a; /// Get the list of shadow parts for this shadow root. fn parts<'a>(&self) -> &[<Self::ConcreteNode as TNode>::ConcreteElement] where - Self: 'a + Self: 'a, { &[] } /// Get a list of elements with a given ID in this shadow root, sorted by /// tree position. /// /// Can return an error to signal that this list is not available, or also @@ -529,17 +529,17 @@ pub trait TElement: /// Internal iterator for the classes of this element. fn each_class<F>(&self, callback: F) where F: FnMut(&Atom); /// Internal iterator for the part names of this element. fn each_part<F>(&self, _callback: F) where - F: FnMut(&Atom) + F: FnMut(&Atom), { } /// Whether a given element may generate a pseudo-element. /// /// This is useful to avoid computing, for example, pseudo styles for /// `::-first-line` or `::-first-letter`, when we know it won't affect us. ///
--- a/servo/components/style/gecko/conversions.rs +++ b/servo/components/style/gecko/conversions.rs @@ -94,17 +94,17 @@ impl nsStyleImage { GenericImage::Element(ref element) => unsafe { bindings::Gecko_SetImageElement(self, element.as_ptr()); }, } } 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)); } } /// Converts into Image. pub unsafe fn into_image(self: &nsStyleImage) -> Option<Image> { use crate::gecko_bindings::structs::nsStyleImageType; use crate::values::computed::{MozImageRect, NumberOrPercentage}; @@ -137,18 +137,17 @@ impl nsStyleImage { "mCropRect could not convert to NumberOrPercentage" ); None }, } } }, 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 => { use crate::gecko_string_cache::Atom; let atom = bindings::Gecko_GetImageElement(self); Some(GenericImage::Element(Atom::from_raw(atom))) }, }
--- a/servo/components/style/gecko/selector_parser.rs +++ b/servo/components/style/gecko/selector_parser.rs @@ -349,19 +349,18 @@ impl<'a, 'i> ::selectors::Parser<'i> for #[inline] fn parse_host(&self) -> bool { true } #[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( &self, location: SourceLocation, name: CowRcStr<'i>, ) -> Result<NonTSPseudoClass, ParseError<'i>> { if let Some(pseudo_class) = NonTSPseudoClass::parse_non_functional(&name) {
--- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -184,17 +184,17 @@ impl<'lr> TShadowRoot for GeckoShadowRoo Ok(elements_with_id(unsafe { bindings::Gecko_ShadowRoot_GetElementsWithId(self.0, id.as_ptr()) })) } #[inline] fn parts<'a>(&self) -> &[<Self::ConcreteNode as TNode>::ConcreteElement] where - Self: 'a + Self: 'a, { let slice: &[*const RawGeckoElement] = &*self.0.mParts; #[allow(dead_code)] unsafe fn static_assert() { mem::transmute::<*const RawGeckoElement, GeckoElement<'static>>(0xbadc0de as *const _); } @@ -1345,17 +1345,18 @@ impl<'le> TElement for GeckoElement<'le> #[inline] fn has_attr(&self, namespace: &Namespace, attr: &Atom) -> bool { unsafe { bindings::Gecko_HasAttr(self.0, namespace.0.as_ptr(), attr.as_ptr()) } } #[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. #[inline] fn id(&self) -> Option<&WeakAtom> { if !self.has_id() { return None; }
--- a/servo/components/style/invalidation/element/invalidator.rs +++ b/servo/components/style/invalidation/element/invalidator.rs @@ -73,17 +73,18 @@ pub struct DescendantInvalidationLists<' /// Invalidations for slotted children of an element. pub slotted_descendants: InvalidationVector<'a>, /// Invalidations for ::part()s of an element. pub parts: InvalidationVector<'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() } } /// The struct that takes care of encapsulating all the logic on where and how /// element styles need to be invalidated. pub struct TreeStyleInvalidator<'a, 'b, E, P: 'a> where @@ -174,19 +175,17 @@ impl<'a> Invalidation<'a> { if self.offset == 0 { return InvalidationKind::Descendant(DescendantInvalidationKind::Dom); } match self.selector.combinator_at_parse_order(self.offset - 1) { 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) }, Combinator::NextSibling | Combinator::LaterSibling => InvalidationKind::Sibling, } } } @@ -501,17 +500,16 @@ where "::part() shouldn't have sibling combinators to the right, \ this makes no sense! {:?}", sibling_invalidations ); } any } - fn invalidate_slotted_elements(&mut self, invalidations: &[Invalidation<'b>]) -> bool { if invalidations.is_empty() { return false; } let slot = self.element; self.invalidate_slotted_elements_in_slot(slot, invalidations) }
--- a/servo/components/style/media_queries/media_feature_expression.rs +++ b/servo/components/style/media_queries/media_feature_expression.rs @@ -293,18 +293,17 @@ impl MediaFeatureExpression { requirements.insert(ParsingRequirements::CHROME_AND_UA_ONLY); } let result = { let mut feature_name = &**ident; #[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 { structs::StaticPrefs_sVarCache_layout_css_prefixes_device_pixel_ratio_webkit } { requirements.insert( ParsingRequirements::WEBKIT_DEVICE_PIXEL_RATIO_PREF_ENABLED, );
--- a/servo/components/style/properties/data.py +++ b/servo/components/style/properties/data.py @@ -160,19 +160,21 @@ def arg_to_bool(arg): def parse_property_aliases(alias_list): result = [] if alias_list: for alias in alias_list.split(): (name, _, pref) = alias.partition(":") 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, enabled_in="content", need_index=False, gecko_ffi_name=None, allowed_in_keyframe_block=True, cast_type='u8', logical=False, logical_group=None, alias=None, extra_prefixes=None, boxed=False, flags=None, allowed_in_page_rule=False, allow_quirks="No", @@ -242,17 +244,17 @@ class Longhand(object): def type(): return "longhand" # For a given logical property return all the physical # property names corresponding to it. 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] physical = PHYSICAL_SIDES if logical_side in LOGICAL_SIDES \ else PHYSICAL_SIZES if logical_side in LOGICAL_SIZES \ else PHYSICAL_AXES if logical_side in LOGICAL_AXES \ else LOGICAL_CORNERS return [to_phys(self.name, logical_side, physical_side)
--- a/servo/components/style/rule_collector.rs +++ b/servo/components/style/rule_collector.rs @@ -327,27 +327,24 @@ where let shadow = match self.rule_hash_target.containing_shadow() { Some(s) => s, None => return, }; 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 // need an OuterTreeAuthorNormal cascade level or such, and change the // cascade order, if we allow to forward parts to even outer trees. // // Though the current thing kinda works because we apply them after // the outer tree, so as long as we don't allow forwarding we're
--- a/servo/components/style/selector_map.rs +++ b/servo/components/style/selector_map.rs @@ -253,17 +253,17 @@ impl SelectorMap<Rule> { context, flags_setter, cascade_level, shadow_cascade_order, ); } /// 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, context: &mut MatchingContext<E::Impl>, flags_setter: &mut F, cascade_level: CascadeLevel, shadow_cascade_order: ShadowCascadeOrder, ) where
--- a/servo/components/style/values/computed/image.rs +++ b/servo/components/style/values/computed/image.rs @@ -61,20 +61,20 @@ pub type ColorStop = generic::ColorStop< pub type MozImageRect = generic::MozImageRect<NumberOrPercentage, ComputedImageUrl>; impl generic::LineDirection for LineDirection { fn points_downwards(&self, compat_mode: GradientCompatMode) -> bool { match *self { LineDirection::Angle(angle) => angle.radians() == PI, LineDirection::Vertical(VerticalPositionKeyword::Bottom) => { compat_mode == GradientCompatMode::Modern - } + }, LineDirection::Vertical(VerticalPositionKeyword::Top) => { compat_mode != GradientCompatMode::Modern - } + }, _ => false, } } fn to_css<W>(&self, dest: &mut CssWriter<W>, compat_mode: GradientCompatMode) -> fmt::Result where W: Write, {
--- a/servo/components/style/values/generics/image.rs +++ b/servo/components/style/values/generics/image.rs @@ -10,17 +10,26 @@ use crate::custom_properties; use crate::values::serialize_atom_identifier; use crate::Atom; use servo_arc::Arc; use std::fmt::{self, Write}; 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. None, /// The `<image>` value. Image(Image), }
--- a/servo/components/style/values/specified/image.rs +++ b/servo/components/style/values/specified/image.rs @@ -6,20 +6,22 @@ //! [`image`][image]s //! //! [image]: https://drafts.csswg.org/css-images/#image-values 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::{HorizontalPositionKeyword, VerticalPositionKeyword}; use crate::values::specified::position::{Position, PositionComponent, Side}; -use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword}; use crate::values::specified::url::SpecifiedImageUrl; use crate::values::specified::{Angle, Color, Length, LengthPercentage}; use crate::values::specified::{Number, NumberOrPercentage, Percentage}; use crate::Atom; use cssparser::{Delimiter, Parser, Token}; use selectors::parser::SelectorParseErrorKind; #[cfg(feature = "servo")] use servo_url::ServoUrl; @@ -245,26 +247,33 @@ impl Parse for Gradient { let items = GradientItem::parse_comma_separated(context, i)?; Ok((shape, items)) })?; if items.len() < 2 { return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } - Ok(Gradient { items, repeating, kind, compat_mode }) + Ok(Gradient { + items, + repeating, + kind, + compat_mode, + }) } } impl Gradient { fn parse_webkit_gradient_argument<'i, 't>( 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)] enum Component<S> { Center, Number(NumberOrPercentage), Side(S), } @@ -507,17 +516,19 @@ impl GradientKind { compat_mode: &mut GradientCompatMode, ) -> Result<Self, ParseError<'i>> { let direction = if let Ok(d) = input.try(|i| LineDirection::parse(context, i, compat_mode)) { input.expect_comma()?; d } else { match *compat_mode { - GradientCompatMode::Modern => LineDirection::Vertical(VerticalPositionKeyword::Bottom), + GradientCompatMode::Modern => { + LineDirection::Vertical(VerticalPositionKeyword::Bottom) + }, _ => LineDirection::Vertical(VerticalPositionKeyword::Top), } }; Ok(generic::GradientKind::Linear(direction)) } fn parse_radial<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, @@ -558,20 +569,20 @@ impl GradientKind { } impl generic::LineDirection for LineDirection { fn points_downwards(&self, compat_mode: GradientCompatMode) -> bool { match *self { 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, } } fn to_css<W>(&self, dest: &mut CssWriter<W>, compat_mode: GradientCompatMode) -> fmt::Result where W: Write, { @@ -616,17 +627,19 @@ impl LineDirection { input.try(|i| { let to_ident = i.try(|i| i.expect_ident_matching("to")); match *compat_mode { // `to` keyword is mandatory in modern syntax. GradientCompatMode::Modern => to_ident?, // 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() => { return Err( i.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("to".into())) ); }, _ => {}, @@ -736,17 +749,19 @@ impl EndingShape { } impl ShapeExtent { fn parse_with_compat_mode<'i, 't>( input: &mut Parser<'i, 't>, 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), ShapeExtent::Cover => Ok(ShapeExtent::FarthestCorner), keyword => Ok(keyword), } } }
--- a/servo/components/style/values/specified/position.rs +++ b/servo/components/style/values/specified/position.rs @@ -2,25 +2,25 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! CSS handling for the specified value of //! [`position`][position]s //! //! [position]: https://drafts.csswg.org/css-backgrounds-3/#position -use crate::Atom; +use crate::parser::{Parse, ParserContext}; use crate::selector_map::PrecomputedHashMap; -use crate::parser::{Parse, ParserContext}; 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; use servo_arc::Arc; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; /// The specified value of a CSS `<position>` @@ -574,17 +574,19 @@ impl TemplateAreas { } impl Parse for TemplateAreas { fn parse<'i, 't>( _context: &ParserContext, 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); } TemplateAreas::from_vec(strings) .map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) } }
--- a/servo/components/style/values/specified/transform.rs +++ b/servo/components/style/values/specified/transform.rs @@ -4,17 +4,19 @@ //! Specified types for CSS values that are related to transformations. use crate::parser::{Parse, ParserContext}; use crate::values::computed::{Context, LengthPercentage as ComputedLengthPercentage}; 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; use style_traits::{ParseError, StyleParseErrorKind}; pub use crate::values::generics::transform::TransformStyle; /// A single operation in a specified CSS `transform`