Rustfmt recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-12-15 23:58:55 +01:00
parent e885ccb7ae
commit ef16c5844f
28 changed files with 111 additions and 63 deletions

View file

@ -2548,8 +2548,16 @@ impl Flow for BlockFlow {
.base .base
.flags .flags
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) && .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) &&
self.fragment.style().logical_position().inline_start.is_auto() && self.fragment
self.fragment.style().logical_position().inline_end.is_auto() .style()
.logical_position()
.inline_start
.is_auto() &&
self.fragment
.style()
.logical_position()
.inline_end
.is_auto()
{ {
self.base.position.start.i = inline_position self.base.position.start.i = inline_position
} }
@ -2560,7 +2568,11 @@ impl Flow for BlockFlow {
.base .base
.flags .flags
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) && .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) &&
self.fragment.style().logical_position().block_start.is_auto() && self.fragment
.style()
.logical_position()
.block_start
.is_auto() &&
self.fragment.style().logical_position().block_end.is_auto() self.fragment.style().logical_position().block_end.is_auto()
{ {
self.base.position.start.b = block_position self.base.position.start.b = block_position
@ -2848,11 +2860,8 @@ pub trait ISizeAndMarginsComputer {
parent_flow_inline_size: Au, parent_flow_inline_size: Au,
shared_context: &SharedStyleContext, shared_context: &SharedStyleContext,
) -> MaybeAuto { ) -> MaybeAuto {
let inline_size = self.containing_block_inline_size( let inline_size =
block, self.containing_block_inline_size(block, parent_flow_inline_size, shared_context);
parent_flow_inline_size,
shared_context,
);
MaybeAuto::from_option( MaybeAuto::from_option(
block block

View file

@ -91,7 +91,10 @@ fn convert_gradient_stops(
color, color,
position: None, position: None,
}), }),
GradientItem::ComplexColorStop { color, ref position } => Some(ColorStop { GradientItem::ComplexColorStop {
color,
ref position,
} => Some(ColorStop {
color, color,
position: Some(position.clone()), position: Some(position.clone()),
}), }),
@ -125,7 +128,13 @@ fn convert_gradient_stops(
// //
// FIXME(emilio): Once we know the offsets, it seems like converting the // FIXME(emilio): Once we know the offsets, it seems like converting the
// positions to absolute at once then process that would be cheaper. // positions to absolute at once then process that would be cheaper.
let mut last_stop_position = stop_items.first().unwrap().position.as_ref().unwrap().clone(); let mut last_stop_position = stop_items
.first()
.unwrap()
.position
.as_ref()
.unwrap()
.clone();
for stop in stop_items.iter_mut().skip(1) { for stop in stop_items.iter_mut().skip(1) {
if let Some(ref pos) = stop.position { if let Some(ref pos) = stop.position {
if position_to_offset(&last_stop_position, total_length) > if position_to_offset(&last_stop_position, total_length) >
@ -147,8 +156,10 @@ fn convert_gradient_stops(
// Initialize a new stop run. // Initialize a new stop run.
// `unwrap()` here should never fail because this is the beginning of // `unwrap()` here should never fail because this is the beginning of
// a stop run, which is always bounded by a length or percentage. // a stop run, which is always bounded by a length or percentage.
let start_offset = let start_offset = position_to_offset(
position_to_offset(stop_items[i - 1].position.as_ref().unwrap(), total_length); stop_items[i - 1].position.as_ref().unwrap(),
total_length,
);
// `unwrap()` here should never fail because this is the end of // `unwrap()` here should never fail because this is the end of
// a stop run, which is always bounded by a length or percentage. // a stop run, which is always bounded by a length or percentage.
let (end_index, end_stop) = stop_items[(i + 1)..] let (end_index, end_stop) = stop_items[(i + 1)..]
@ -156,7 +167,8 @@ fn convert_gradient_stops(
.enumerate() .enumerate()
.find(|&(_, ref stop)| stop.position.is_some()) .find(|&(_, ref stop)| stop.position.is_some())
.unwrap(); .unwrap();
let end_offset = position_to_offset(end_stop.position.as_ref().unwrap(), total_length); let end_offset =
position_to_offset(end_stop.position.as_ref().unwrap(), total_length);
stop_run = Some(StopRun { stop_run = Some(StopRun {
start_offset, start_offset,
end_offset, end_offset,

View file

@ -1113,12 +1113,11 @@ impl BaseFlow {
self.flags.set( self.flags.set(
FlowFlags::INLINE_POSITION_IS_STATIC, FlowFlags::INLINE_POSITION_IS_STATIC,
logical_position.inline_start.is_auto() && logical_position.inline_start.is_auto() &&
logical_position.inline_end.is_auto() logical_position.inline_end.is_auto(),
); );
self.flags.set( self.flags.set(
FlowFlags::BLOCK_POSITION_IS_STATIC, FlowFlags::BLOCK_POSITION_IS_STATIC,
logical_position.block_start.is_auto() && logical_position.block_start.is_auto() && logical_position.block_end.is_auto(),
logical_position.block_end.is_auto()
); );
} }
} }

View file

@ -2527,10 +2527,20 @@ impl Fragment {
{ {
continue; continue;
} }
if !inline_context_node.style.logical_margin().inline_end.is_definitely_zero() { if !inline_context_node
.style
.logical_margin()
.inline_end
.is_definitely_zero()
{
return false; return false;
} }
if !inline_context_node.style.logical_padding().inline_end.is_definitely_zero() { if !inline_context_node
.style
.logical_padding()
.inline_end
.is_definitely_zero()
{
return false; return false;
} }
if inline_context_node.style.logical_border_width().inline_end != Au(0) { if inline_context_node.style.logical_border_width().inline_end != Au(0) {
@ -2549,10 +2559,20 @@ impl Fragment {
{ {
continue; continue;
} }
if !inline_context_node.style.logical_margin().inline_start.is_definitely_zero() { if !inline_context_node
.style
.logical_margin()
.inline_start
.is_definitely_zero()
{
return false; return false;
} }
if !inline_context_node.style.logical_padding().inline_start.is_definitely_zero() { if !inline_context_node
.style
.logical_padding()
.inline_start
.is_definitely_zero()
{
return false; return false;
} }
if inline_context_node if inline_context_node

View file

@ -177,11 +177,15 @@ impl flow_relative::Vec2<MaxSize<LengthPercentage>> {
flow_relative::Vec2 { flow_relative::Vec2 {
inline: match self.inline { inline: match self.inline {
MaxSize::None => None, MaxSize::None => None,
MaxSize::LengthPercentage(ref lp) => Some(lp.percentage_relative_to(containing_block.inline_size)), MaxSize::LengthPercentage(ref lp) => {
Some(lp.percentage_relative_to(containing_block.inline_size))
},
}, },
block: match self.block { block: match self.block {
MaxSize::None => None, MaxSize::None => None,
MaxSize::LengthPercentage(ref lp) => lp.maybe_percentage_relative_to(containing_block.block_size.non_auto()), MaxSize::LengthPercentage(ref lp) => {
lp.maybe_percentage_relative_to(containing_block.block_size.non_auto())
},
}, },
} }
} }

View file

@ -180,7 +180,9 @@ impl From<stylo::Display> for Display {
fn size_to_length(size: Size) -> LengthPercentageOrAuto { fn size_to_length(size: Size) -> LengthPercentageOrAuto {
match size { match size {
Size::LengthPercentage(length) => LengthPercentageOrAuto::LengthPercentage(length.0.clone()), Size::LengthPercentage(length) => {
LengthPercentageOrAuto::LengthPercentage(length.0.clone())
},
Size::Auto => LengthPercentageOrAuto::Auto, Size::Auto => LengthPercentageOrAuto::Auto,
} }
} }

View file

@ -324,7 +324,7 @@ where
Component::LastOfType | Component::LastOfType |
Component::OnlyOfType => { Component::OnlyOfType => {
specificity.class_like_selectors += 1; specificity.class_like_selectors += 1;
} },
Component::NonTSPseudoClass(ref pseudo) => { Component::NonTSPseudoClass(ref pseudo) => {
if !pseudo.has_zero_specificity() { if !pseudo.has_zero_specificity() {
specificity.class_like_selectors += 1; specificity.class_like_selectors += 1;

View file

@ -867,14 +867,14 @@ pub trait TElement:
break; break;
} }
inner_shadow = shadow; inner_shadow = shadow;
} },
None => { None => {
// TODO(emilio): Should probably distinguish with // TODO(emilio): Should probably distinguish with
// MatchesDocumentRules::{No,Yes,IfPart} or // MatchesDocumentRules::{No,Yes,IfPart} or
// something so that we could skip some work. // something so that we could skip some work.
doc_rules_apply = true; doc_rules_apply = true;
break; break;
} },
} }
} }
} }

View file

@ -7,8 +7,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use crate::context::SharedStyleContext; use crate::context::SharedStyleContext;
use crate::Atom;
use crate::values::computed::Length; use crate::values::computed::Length;
use crate::Atom;
/// Represents the font metrics that style needs from a font to compute the /// Represents the font metrics that style needs from a font to compute the
/// value of certain CSS units like `ex`. /// value of certain CSS units like `ex`.

View file

@ -138,7 +138,8 @@ impl Device {
/// Set the font size of the root element (for rem) /// Set the font size of the root element (for rem)
pub fn set_root_font_size(&self, size: Au) { pub fn set_root_font_size(&self, size: Au) {
self.root_font_size.store(size.0 as isize, Ordering::Relaxed) self.root_font_size
.store(size.0 as isize, Ordering::Relaxed)
} }
/// Sets the body text color for the "inherit color from body" quirk. /// Sets the body text color for the "inherit color from body" quirk.

View file

@ -1000,7 +1000,8 @@ impl structs::FontSizePrefs {
GenericFontFamily::MozEmoji => unreachable!( GenericFontFamily::MozEmoji => unreachable!(
"Should never get here, since this doesn't (yet) appear on font family" "Should never get here, since this doesn't (yet) appear on font family"
), ),
}).into() })
.into()
} }
} }
@ -2131,7 +2132,9 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
true true
}, },
NonTSPseudoClass::MozNativeAnonymous | NonTSPseudoClass::MozNativeAnonymous |
NonTSPseudoClass::MozNativeAnonymousNoSpecificity => self.is_in_native_anonymous_subtree(), NonTSPseudoClass::MozNativeAnonymousNoSpecificity => {
self.is_in_native_anonymous_subtree()
},
NonTSPseudoClass::MozUseShadowTreeRoot => self.is_root_of_use_element_shadow_tree(), NonTSPseudoClass::MozUseShadowTreeRoot => self.is_root_of_use_element_shadow_tree(),
NonTSPseudoClass::MozTableBorderNonzero => unsafe { NonTSPseudoClass::MozTableBorderNonzero => unsafe {
bindings::Gecko_IsTableBorderNonzero(self.0) bindings::Gecko_IsTableBorderNonzero(self.0)

View file

@ -396,9 +396,11 @@ impl<'a> SelectorVisitor for CompoundSelectorDependencyCollector<'a> {
if may_match_in_no_namespace { if may_match_in_no_namespace {
if *local_name_lower == local_name!("id") { if *local_name_lower == local_name!("id") {
self.flags.insert(InvalidationMapFlags::HAS_ID_ATTR_SELECTOR) self.flags
.insert(InvalidationMapFlags::HAS_ID_ATTR_SELECTOR)
} else if *local_name_lower == local_name!("class") { } else if *local_name_lower == local_name!("class") {
self.flags.insert(InvalidationMapFlags::HAS_CLASS_ATTR_SELECTOR) self.flags
.insert(InvalidationMapFlags::HAS_CLASS_ATTR_SELECTOR)
} }
} }

View file

@ -204,7 +204,10 @@ where
} }
if log_enabled!(::log::Level::Debug) { if log_enabled!(::log::Level::Debug) {
debug!("Collecting changes for: {:?}, flags {:?}", element, attr_selector_flags); debug!(
"Collecting changes for: {:?}, flags {:?}",
element, attr_selector_flags
);
if !state_changes.is_empty() { if !state_changes.is_empty() {
debug!(" > state: {:?}", state_changes); debug!(" > state: {:?}", state_changes);
} }
@ -362,8 +365,8 @@ where
} }
} }
let should_examine_attribute_selector_map = self.snapshot.other_attr_changed() || let should_examine_attribute_selector_map =
map.flags.intersects(self.attr_selector_flags); self.snapshot.other_attr_changed() || map.flags.intersects(self.attr_selector_flags);
if should_examine_attribute_selector_map { if should_examine_attribute_selector_map {
self.collect_dependencies_in_map(&map.other_attribute_affecting_selectors) self.collect_dependencies_in_map(&map.other_attribute_affecting_selectors)

View file

@ -916,7 +916,6 @@ impl<T> LogicalMargin<T> {
} }
} }
impl<T: Copy> LogicalMargin<T> { impl<T: Copy> LogicalMargin<T> {
#[inline] #[inline]
pub fn new_all_same(mode: WritingMode, value: T) -> LogicalMargin<T> { pub fn new_all_same(mode: WritingMode, value: T) -> LogicalMargin<T> {

View file

@ -348,7 +348,6 @@ where
return; return;
} }
let inner_shadow_host = inner_shadow.host(); let inner_shadow_host = inner_shadow.host();
let outer_shadow = inner_shadow_host.containing_shadow(); let outer_shadow = inner_shadow_host.containing_shadow();
let part_rules = match outer_shadow { let part_rules = match outer_shadow {

View file

@ -592,8 +592,8 @@ impl RuleTree {
last = node; last = node;
} }
let rule = let rule = self
self.insert_ordered_rules_from(last.parent().unwrap().clone(), children.drain(..).rev()); .insert_ordered_rules_from(last.parent().unwrap().clone(), children.drain(..).rev());
rule rule
} }

View file

@ -11,8 +11,8 @@ use crate::media_queries::media_feature_expression::RangeOrOperator;
use crate::media_queries::MediaType; use crate::media_queries::MediaType;
use crate::properties::ComputedValues; use crate::properties::ComputedValues;
use crate::values::computed::CSSPixelLength; use crate::values::computed::CSSPixelLength;
use crate::values::KeyframesName;
use crate::values::specified::font::FONT_MEDIUM_PX; use crate::values::specified::font::FONT_MEDIUM_PX;
use crate::values::KeyframesName;
use app_units::Au; use app_units::Au;
use cssparser::RGBA; use cssparser::RGBA;
use euclid::default::Size2D as UntypedSize2D; use euclid::default::Size2D as UntypedSize2D;

View file

@ -59,8 +59,8 @@ pub use self::rules_iterator::{AllRules, EffectiveRules};
pub use self::rules_iterator::{NestedRuleIterationCondition, RulesIterator}; pub use self::rules_iterator::{NestedRuleIterationCondition, RulesIterator};
pub use self::style_rule::StyleRule; pub use self::style_rule::StyleRule;
pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet}; pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet};
pub use self::stylesheet::{StylesheetContents, StylesheetInDocument, UserAgentStylesheets};
pub use self::stylesheet::{SanitizationData, SanitizationKind}; pub use self::stylesheet::{SanitizationData, SanitizationKind};
pub use self::stylesheet::{StylesheetContents, StylesheetInDocument, UserAgentStylesheets};
pub use self::supports_rule::SupportsRule; pub use self::supports_rule::SupportsRule;
pub use self::viewport_rule::ViewportRule; pub use self::viewport_rule::ViewportRule;

View file

@ -368,9 +368,7 @@ impl SanitizationKind {
CssRule::Supports(..) | CssRule::Supports(..) |
CssRule::Import(..) => false, CssRule::Import(..) => false,
CssRule::FontFace(..) | CssRule::FontFace(..) | CssRule::Namespace(..) | CssRule::Style(..) => true,
CssRule::Namespace(..) |
CssRule::Style(..) => true,
CssRule::Keyframes(..) | CssRule::Keyframes(..) |
CssRule::Page(..) | CssRule::Page(..) |

View file

@ -1373,11 +1373,7 @@ impl ComputedTranslate {
LengthPercentage::zero(), LengthPercentage::zero(),
Length::zero(), Length::zero(),
), ),
Translate::Translate(ref tx, ref ty, ref tz) => ( Translate::Translate(ref tx, ref ty, ref tz) => (tx.clone(), ty.clone(), tz.clone()),
tx.clone(),
ty.clone(),
tz.clone(),
),
} }
} }
} }

View file

@ -75,9 +75,7 @@ impl ToComputedValue for specified::Length {
/// ///
/// https://drafts.csswg.org/css-values-4/#typedef-length-percentage /// https://drafts.csswg.org/css-values-4/#typedef-length-percentage
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive( #[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, ToAnimatedZero, ToResolvedValue)]
Clone, Debug, Deserialize, MallocSizeOf, Serialize, ToAnimatedZero, ToResolvedValue,
)]
#[repr(C)] #[repr(C)]
pub struct LengthPercentage { pub struct LengthPercentage {
length: Length, length: Length,

View file

@ -75,11 +75,11 @@ pub use self::resolution::Resolution;
pub use self::svg::MozContextProperties; pub use self::svg::MozContextProperties;
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind}; pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::text::TextUnderlinePosition;
pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight}; pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight};
pub use self::text::{OverflowWrap, TextOverflow, WordBreak, WordSpacing}; pub use self::text::{OverflowWrap, TextOverflow, WordBreak, WordSpacing};
pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle}; pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle};
pub use self::text::{TextDecorationLength, TextDecorationSkipInk}; pub use self::text::{TextDecorationLength, TextDecorationSkipInk};
pub use self::text::TextUnderlinePosition;
pub use self::time::Time; pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform, TransformOperation}; pub use self::transform::{Rotate, Scale, Transform, TransformOperation};
pub use self::transform::{TransformOrigin, TransformStyle, Translate}; pub use self::transform::{TransformOrigin, TransformStyle, Translate};

View file

@ -19,10 +19,10 @@ use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss}; use style_traits::{CssWriter, ToCss};
pub use crate::values::specified::TextAlignKeyword as TextAlign; pub use crate::values::specified::TextAlignKeyword as TextAlign;
pub use crate::values::specified::TextUnderlinePosition;
pub use crate::values::specified::{LineBreak, OverflowWrap, WordBreak}; pub use crate::values::specified::{LineBreak, OverflowWrap, WordBreak};
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition}; pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
pub use crate::values::specified::{TextDecorationSkipInk, TextTransform}; pub use crate::values::specified::{TextDecorationSkipInk, TextTransform};
pub use crate::values::specified::TextUnderlinePosition;
/// A computed value for the `initial-letter` property. /// A computed value for the `initial-letter` property.
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>; pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;

View file

@ -390,11 +390,9 @@ impl Display {
Display::from3(DisplayOutside::Block, inside, self.is_list_item()) Display::from3(DisplayOutside::Block, inside, self.is_list_item())
}, },
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
DisplayOutside::XUL => { DisplayOutside::XUL => match self.inside() {
match self.inside() { DisplayInside::MozInlineBox | DisplayInside::MozBox => Display::MozBox,
DisplayInside::MozInlineBox | DisplayInside::MozBox => Display::MozBox, _ => Display::Block,
_ => Display::Block,
}
}, },
DisplayOutside::Block | DisplayOutside::None => *self, DisplayOutside::Block | DisplayOutside::None => *self,
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))] #[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]

View file

@ -961,7 +961,8 @@ impl FontSize {
// others should reject negatives during parsing. But SMIL // others should reject negatives during parsing. But SMIL
// allows parsing negatives, and relies on us _not_ doing that // allows parsing negatives, and relies on us _not_ doing that
// clamping. That's so bonkers :( // clamping. That's so bonkers :(
calc.percentage_relative_to(base_size.resolve(context)).clamp_to_non_negative() calc.percentage_relative_to(base_size.resolve(context))
.clamp_to_non_negative()
}, },
FontSize::Keyword(i) => { FontSize::Keyword(i) => {
// As a specified keyword, this is keyword derived // As a specified keyword, this is keyword derived

View file

@ -5,7 +5,7 @@
//! Specified types for legacy Gecko-only properties. //! Specified types for legacy Gecko-only properties.
use crate::parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
use crate::values::computed::{self, LengthPercentage, Length}; use crate::values::computed::{self, Length, LengthPercentage};
use crate::values::generics::rect::Rect; use crate::values::generics::rect::Rect;
use cssparser::{Parser, Token}; use cssparser::{Parser, Token};
use std::fmt; use std::fmt;

View file

@ -101,7 +101,11 @@ impl FontRelativeLength {
} }
/// Computes the font-relative length. /// Computes the font-relative length.
pub fn to_computed_value(&self, context: &Context, base_size: FontBaseSize) -> computed::Length { pub fn to_computed_value(
&self,
context: &Context,
base_size: FontBaseSize,
) -> computed::Length {
let (reference_size, length) = self.reference_font_size_and_length(context, base_size); let (reference_size, length) = self.reference_font_size_and_length(context, base_size);
reference_size * length reference_size * length
} }

View file

@ -80,11 +80,11 @@ pub use self::svg::MozContextProperties;
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint}; pub use self::svg::{SVGLength, SVGOpacity, SVGPaint};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::svg_path::SVGPathData; pub use self::svg_path::SVGPathData;
pub use self::text::TextUnderlinePosition;
pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight, TextAlign}; pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight, TextAlign};
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak}; pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing}; pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
pub use self::text::{TextDecorationLength, TextDecorationSkipInk, TextTransform}; pub use self::text::{TextDecorationLength, TextDecorationSkipInk, TextTransform};
pub use self::text::TextUnderlinePosition;
pub use self::time::Time; pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform}; pub use self::transform::{Rotate, Scale, Transform};
pub use self::transform::{TransformOrigin, TransformStyle, Translate}; pub use self::transform::{TransformOrigin, TransformStyle, Translate};