Skip to content

Commit

Permalink
style: Reformat recent changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Apr 16, 2020
1 parent 7c96aed commit f76acc8
Show file tree
Hide file tree
Showing 30 changed files with 329 additions and 190 deletions.
5 changes: 4 additions & 1 deletion components/selectors/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,10 @@ where
// given selector is allowed to match a featureless element,
// it must do so while ignoring the default namespace.
//
if !matches!(result, SimpleSelectorParseResult::SimpleSelector(Component::Host(..))) {
if !matches!(
result,
SimpleSelectorParseResult::SimpleSelector(Component::Host(..))
) {
builder.push_simple_selector(Component::DefaultNamespace(url));
}
}
Expand Down
8 changes: 6 additions & 2 deletions components/style/counter_style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ impl ToCss for System {
}

/// <https://drafts.csswg.org/css-counter-styles/#typedef-symbol>
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem)]
#[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem,
)]
#[repr(u8)]
pub enum Symbol {
/// <string>
Expand Down Expand Up @@ -554,7 +556,9 @@ impl Parse for Fallback {
}

/// <https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-symbols>
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem)]
#[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem,
)]
#[repr(C)]
pub struct Symbols(#[css(iterable)] pub crate::OwnedSlice<Symbol>);

Expand Down
6 changes: 3 additions & 3 deletions components/style/custom_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
// Don't touch the map, this has the same effect as
// making it compute to the inherited one.
return;
}
},
}
} else {
(*unparsed_value).clone()
Expand Down Expand Up @@ -848,7 +848,7 @@ fn substitute_all(
match result {
Ok(computed_value) => {
context.map.insert(name, Arc::new(computed_value));
}
},
Err(..) => {
// This is invalid, reset it to the unset (inherited) value.
let inherited = context.inherited.and_then(|m| m.get(&name)).cloned();
Expand All @@ -860,7 +860,7 @@ fn substitute_all(
context.map.remove(&name);
},
};
}
},
}

// All resolved, so return the signal value.
Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![allow(unsafe_code)]

use crate::gecko_bindings::structs::{Matrix4x4Components, nsresult};
use crate::gecko_bindings::structs::{nsresult, Matrix4x4Components};
use crate::stylesheets::RulesMutateError;
use crate::values::computed::transform::Matrix3D;

Expand Down
4 changes: 3 additions & 1 deletion components/style/gecko/media_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ impl Device {
let mut right = 0.0;
let mut bottom = 0.0;
let mut left = 0.0;
unsafe { bindings::Gecko_GetSafeAreaInsets(pc, &mut top, &mut right, &mut bottom, &mut left) };
unsafe {
bindings::Gecko_GetSafeAreaInsets(pc, &mut top, &mut right, &mut bottom, &mut left)
};
SideOffsets2D::new(top, right, bottom, left)
}
}
2 changes: 1 addition & 1 deletion components/style/gecko/selector_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl NonTSPseudoClass {
#[inline]
fn is_enabled_in_content(&self) -> bool {
if matches!(*self, NonTSPseudoClass::FocusVisible) {
return static_prefs::pref!("layout.css.focus-visible.enabled")
return static_prefs::pref!("layout.css.focus-visible.enabled");
}
!self.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME)
}
Expand Down
8 changes: 1 addition & 7 deletions components/style/gecko/snapshot_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@ pub(super) fn each_exported_part(
None => return,
};
let mut length = 0;
let atoms = unsafe {
bindings::Gecko_Element_ExportedParts(
attr,
name.as_ptr(),
&mut length,
)
};
let atoms = unsafe { bindings::Gecko_Element_ExportedParts(attr, name.as_ptr(), &mut length) };
if atoms.is_null() {
return;
}
Expand Down
13 changes: 12 additions & 1 deletion components/style/gecko_string_cache/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ macro_rules! ns {
}

/// A Gecko namespace is just a wrapped atom.
#[derive(Clone, Debug, Default, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
#[derive(
Clone,
Debug,
Default,
Eq,
Hash,
MallocSizeOf,
PartialEq,
ToComputedValue,
ToResolvedValue,
ToShmem,
)]
#[repr(transparent)]
pub struct Namespace(pub Atom);

Expand Down
20 changes: 5 additions & 15 deletions components/style/rule_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ where
self.context.current_host = host.map(|e| e.opaque());
f(self);
if start != self.rules.len() {
self.rules[start..].sort_unstable_by_key(|block| (block.specificity, block.source_order()));
self.rules[start..]
.sort_unstable_by_key(|block| (block.specificity, block.source_order()));
}
self.context.current_host = old_host;
self.in_sort_scope = false;
Expand Down Expand Up @@ -214,11 +215,7 @@ where
}

#[inline]
fn collect_rules_in_list(
&mut self,
part_rules: &[Rule],
cascade_level: CascadeLevel,
) {
fn collect_rules_in_list(&mut self, part_rules: &[Rule], cascade_level: CascadeLevel) {
debug_assert!(self.in_sort_scope, "Rules gotta be sorted");
SelectorMap::get_matching_rules(
self.element,
Expand All @@ -231,11 +228,7 @@ where
}

#[inline]
fn collect_rules_in_map(
&mut self,
map: &SelectorMap<Rule>,
cascade_level: CascadeLevel,
) {
fn collect_rules_in_map(&mut self, map: &SelectorMap<Rule>, cascade_level: CascadeLevel) {
debug_assert!(self.in_sort_scope, "Rules gotta be sorted");
map.get_all_matching_rules(
self.element,
Expand Down Expand Up @@ -413,10 +406,7 @@ where
self.in_tree(containing_host, |collector| {
for p in &parts {
if let Some(part_rules) = part_rules.get(p) {
collector.collect_rules_in_list(
part_rules,
cascade_level,
);
collector.collect_rules_in_list(part_rules, cascade_level);
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions components/style/style_adjuster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {

if !display.is_contents() {
if !self
.style
.get_text()
.clone_text_decoration_line()
.is_empty()
.style
.get_text()
.clone_text_decoration_line()
.is_empty()
{
self.style
.add_flags(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylesheets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ pub use self::rule_parser::{InsertRuleContext, State, TopLevelRuleParser};
pub use self::rules_iterator::{AllRules, EffectiveRules};
pub use self::rules_iterator::{NestedRuleIterationCondition, RulesIterator};
pub use self::style_rule::StyleRule;
pub use self::stylesheet::{AllowImportRules, SanitizationData, SanitizationKind};
pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet};
pub use self::stylesheet::{SanitizationData, SanitizationKind, AllowImportRules};
pub use self::stylesheet::{StylesheetContents, StylesheetInDocument, UserAgentStylesheets};
pub use self::supports_rule::SupportsRule;
pub use self::viewport_rule::ViewportRule;
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylesheets/rule_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::str::CssStringWriter;
use crate::stylesheets::loader::StylesheetLoader;
use crate::stylesheets::rule_parser::{InsertRuleContext, State};
use crate::stylesheets::stylesheet::StylesheetContents;
use crate::stylesheets::{CssRule, RulesMutateError, AllowImportRules};
use crate::stylesheets::{AllowImportRules, CssRule, RulesMutateError};
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
use servo_arc::{Arc, RawOffsetArc};
Expand Down
4 changes: 1 addition & 3 deletions components/style/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,7 @@ where
if let Some(ref values) = data.styles.primary {
for image in &values.get_background().background_image.0 {
let (name, arguments) = match *image {
Image::PaintWorklet(ref worklet) => {
(&worklet.name, &worklet.arguments)
},
Image::PaintWorklet(ref worklet) => (&worklet.name, &worklet.arguments),
_ => continue,
};
let painter = match context.shared.registered_speculative_painters.get(name) {
Expand Down
29 changes: 24 additions & 5 deletions components/style/values/computed/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ impl ToCss for FontFamily {
}
}

#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
#[derive(
Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem,
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
/// The name of a font family of choice
pub struct FamilyName {
Expand Down Expand Up @@ -270,7 +272,9 @@ impl ToCss for FamilyName {
}
}

#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
#[derive(
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem,
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
/// Font family names must either be given quoted as strings,
/// or unquoted as a sequence of one or more identifiers.
Expand All @@ -285,7 +289,9 @@ pub enum FontFamilyNameSyntax {
Identifiers,
}

#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToComputedValue, ToResolvedValue, ToShmem)]
#[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToComputedValue, ToResolvedValue, ToShmem,
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, Hash))]
/// A set of faces that vary in weight, width or slope.
pub enum SingleFontFamily {
Expand All @@ -301,7 +307,18 @@ pub enum SingleFontFamily {
/// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s
/// sSingleGenerics are updated as well.
#[derive(
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss, ToComputedValue, ToResolvedValue, ToShmem,
Clone,
Copy,
Debug,
Eq,
Hash,
MallocSizeOf,
PartialEq,
Parse,
ToCss,
ToComputedValue,
ToResolvedValue,
ToShmem,
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[repr(u8)]
Expand Down Expand Up @@ -427,7 +444,9 @@ impl SingleFontFamily {
}

#[cfg(feature = "servo")]
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
#[derive(
Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem,
)]
/// A list of SingleFontFamily
pub struct FontFamilyList(Box<[SingleFontFamily]>);

Expand Down
3 changes: 2 additions & 1 deletion components/style/values/computed/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use crate::values::computed::url::ComputedImageUrl;
use crate::values::computed::NumberOrPercentage;
use crate::values::computed::{Angle, Color, Context};
use crate::values::computed::{
AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage, ToComputedValue,
AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage,
ToComputedValue,
};
use crate::values::generics::image::{self as generic, GradientCompatMode};
use crate::values::specified::image::LineDirection as SpecifiedLineDirection;
Expand Down
Loading

0 comments on commit f76acc8

Please sign in to comment.