Run rustfmt on selectors, servo_arc, and style.

This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
This commit is contained in:
Bobby Holley 2018-04-10 17:35:15 -07:00
parent f7ae1a37e3
commit c99bcdd4b8
181 changed files with 9981 additions and 7933 deletions

View file

@ -6,7 +6,7 @@
use applicable_declarations::ApplicableDeclarationList;
use context::{CascadeInputs, ElementCascadeInputs, StyleContext};
use data::{ElementStyles, EagerPseudoStyles};
use data::{EagerPseudoStyles, ElementStyles};
use dom::TElement;
use log::Level::Trace;
use matching::MatchMethods;
@ -99,7 +99,10 @@ where
layout_parent_style = Some(layout_parent_data.styles.primary());
}
f(parent_style.map(|x| &**x), layout_parent_style.map(|s| &**s))
f(
parent_style.map(|x| &**x),
layout_parent_style.map(|s| &**s),
)
}
fn eager_pseudo_is_definitely_not_generated(
@ -113,12 +116,14 @@ fn eager_pseudo_is_definitely_not_generated(
}
if !style.flags.intersects(ComputedValueFlags::INHERITS_DISPLAY) &&
style.get_box().clone_display() == Display::None {
style.get_box().clone_display() == Display::None
{
return true;
}
if !style.flags.intersects(ComputedValueFlags::INHERITS_CONTENT) &&
style.ineffective_content_property() {
style.ineffective_content_property()
{
return true;
}
@ -153,21 +158,19 @@ where
parent_style: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
) -> PrimaryStyle {
let primary_results =
self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
let primary_results = self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
let inside_link =
parent_style.map_or(false, |s| s.visited_style().is_some());
let inside_link = parent_style.map_or(false, |s| s.visited_style().is_some());
let visited_rules =
if self.context.shared.visited_styles_enabled &&
(inside_link || self.element.is_link()) {
let visited_matching_results =
self.match_primary(VisitedHandlingMode::RelevantLinkVisited);
Some(visited_matching_results.rule_node)
} else {
None
};
let visited_rules = if self.context.shared.visited_styles_enabled &&
(inside_link || self.element.is_link())
{
let visited_matching_results =
self.match_primary(VisitedHandlingMode::RelevantLinkVisited);
Some(visited_matching_results.rule_node)
} else {
None
};
self.cascade_primary_style(
CascadeInputs {
@ -188,9 +191,7 @@ where
// Before doing the cascade, check the sharing cache and see if we can
// reuse the style via rule node identity.
let may_reuse =
!self.element.is_native_anonymous() &&
parent_style.is_some() &&
inputs.rules.is_some();
!self.element.is_native_anonymous() && parent_style.is_some() && inputs.rules.is_some();
if may_reuse {
let cached = self.context.thread_local.sharing_cache.lookup_by_rules(
@ -226,28 +227,27 @@ where
parent_style: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
) -> ResolvedElementStyles {
let primary_style =
self.resolve_primary_style(parent_style, layout_parent_style);
let primary_style = self.resolve_primary_style(parent_style, layout_parent_style);
let mut pseudo_styles = EagerPseudoStyles::default();
if self.element.implemented_pseudo_element().is_none() {
let layout_parent_style_for_pseudo =
if primary_style.style().is_display_contents() {
layout_parent_style
} else {
Some(primary_style.style())
};
let layout_parent_style_for_pseudo = if primary_style.style().is_display_contents() {
layout_parent_style
} else {
Some(primary_style.style())
};
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
let pseudo_style = self.resolve_pseudo_style(
&pseudo,
&primary_style,
layout_parent_style_for_pseudo
layout_parent_style_for_pseudo,
);
if let Some(style) = pseudo_style {
if !matches!(self.pseudo_resolution, PseudoElementResolution::Force) &&
eager_pseudo_is_definitely_not_generated(&pseudo, &style.0) {
eager_pseudo_is_definitely_not_generated(&pseudo, &style.0)
{
return;
}
pseudo_styles.set(&pseudo, style.0);
@ -279,7 +279,7 @@ where
inputs,
parent_style,
layout_parent_style,
/* pseudo = */ None
/* pseudo = */ None,
)
})
}
@ -318,7 +318,7 @@ where
&self.context.shared.guards,
&values,
pseudo,
&conditions
&conditions,
);
ResolvedStyle(values)
@ -330,35 +330,32 @@ where
inputs: ElementCascadeInputs,
) -> ResolvedElementStyles {
with_default_parent_styles(self.element, move |parent_style, layout_parent_style| {
let primary_style = self.cascade_primary_style(
inputs.primary,
parent_style,
layout_parent_style,
);
let primary_style =
self.cascade_primary_style(inputs.primary, parent_style, layout_parent_style);
let mut pseudo_styles = EagerPseudoStyles::default();
if let Some(mut pseudo_array) = inputs.pseudos.into_array() {
let layout_parent_style_for_pseudo =
if primary_style.style().is_display_contents() {
layout_parent_style
} else {
Some(primary_style.style())
};
let layout_parent_style_for_pseudo = if primary_style.style().is_display_contents()
{
layout_parent_style
} else {
Some(primary_style.style())
};
for (i, inputs) in pseudo_array.iter_mut().enumerate() {
if let Some(inputs) = inputs.take() {
let pseudo = PseudoElement::from_eager_index(i);
let style =
self.cascade_style_and_visited(
inputs,
Some(primary_style.style()),
layout_parent_style_for_pseudo,
Some(&pseudo),
);
let style = self.cascade_style_and_visited(
inputs,
Some(primary_style.style()),
layout_parent_style_for_pseudo,
Some(&pseudo),
);
if !matches!(self.pseudo_resolution, PseudoElementResolution::Force) &&
eager_pseudo_is_definitely_not_generated(&pseudo, &style.0) {
eager_pseudo_is_definitely_not_generated(&pseudo, &style.0)
{
continue;
}
@ -383,7 +380,7 @@ where
let rules = self.match_pseudo(
originating_element_style.style(),
pseudo,
VisitedHandlingMode::AllLinksUnvisited
VisitedHandlingMode::AllLinksUnvisited,
)?;
let mut visited_rules = None;
@ -398,7 +395,7 @@ where
Some(self.cascade_style_and_visited(
CascadeInputs {
rules: Some(rules),
visited_rules
visited_rules,
},
Some(originating_element_style.style()),
layout_parent_style,
@ -406,25 +403,23 @@ where
))
}
fn match_primary(
&mut self,
visited_handling: VisitedHandlingMode,
) -> MatchingResults {
debug!("Match primary for {:?}, visited: {:?}",
self.element, visited_handling);
fn match_primary(&mut self, visited_handling: VisitedHandlingMode) -> MatchingResults {
debug!(
"Match primary for {:?}, visited: {:?}",
self.element, visited_handling
);
let mut applicable_declarations = ApplicableDeclarationList::new();
let map = &mut self.context.thread_local.selector_flags;
let bloom_filter = self.context.thread_local.bloom_filter.filter();
let nth_index_cache = &mut self.context.thread_local.nth_index_cache;
let mut matching_context =
MatchingContext::new_for_visited(
MatchingMode::Normal,
Some(bloom_filter),
Some(nth_index_cache),
visited_handling,
self.context.shared.quirks_mode(),
);
let mut matching_context = MatchingContext::new_for_visited(
MatchingMode::Normal,
Some(bloom_filter),
Some(nth_index_cache),
visited_handling,
self.context.shared.quirks_mode(),
);
let stylist = &self.context.shared.stylist;
let implemented_pseudo = self.element.implemented_pseudo_element();
@ -451,10 +446,9 @@ where
// FIXME(emilio): This is a hack for animations, and should go away.
self.element.unset_dirty_style_attribute();
let rule_node = stylist.rule_tree().compute_rule_node(
&mut applicable_declarations,
&self.context.shared.guards
);
let rule_node = stylist
.rule_tree()
.compute_rule_node(&mut applicable_declarations, &self.context.shared.guards);
if log_enabled!(Trace) {
trace!("Matched rules for {:?}:", self.element);
@ -466,7 +460,7 @@ where
}
}
MatchingResults { rule_node, }
MatchingResults { rule_node }
}
fn match_pseudo(
@ -475,31 +469,36 @@ where
pseudo_element: &PseudoElement,
visited_handling: VisitedHandlingMode,
) -> Option<StrongRuleNode> {
debug!("Match pseudo {:?} for {:?}, visited: {:?}",
self.element, pseudo_element, visited_handling);
debug!(
"Match pseudo {:?} for {:?}, visited: {:?}",
self.element, pseudo_element, visited_handling
);
debug_assert!(pseudo_element.is_eager());
debug_assert!(self.element.implemented_pseudo_element().is_none(),
"Element pseudos can't have any other pseudo.");
debug_assert!(
self.element.implemented_pseudo_element().is_none(),
"Element pseudos can't have any other pseudo."
);
let mut applicable_declarations = ApplicableDeclarationList::new();
let stylist = &self.context.shared.stylist;
if !self.element.may_generate_pseudo(pseudo_element, originating_element_style) {
if !self.element
.may_generate_pseudo(pseudo_element, originating_element_style)
{
return None;
}
let bloom_filter = self.context.thread_local.bloom_filter.filter();
let nth_index_cache = &mut self.context.thread_local.nth_index_cache;
let mut matching_context =
MatchingContext::new_for_visited(
MatchingMode::ForStatelessPseudoElement,
Some(bloom_filter),
Some(nth_index_cache),
visited_handling,
self.context.shared.quirks_mode(),
);
let mut matching_context = MatchingContext::new_for_visited(
MatchingMode::ForStatelessPseudoElement,
Some(bloom_filter),
Some(nth_index_cache),
visited_handling,
self.context.shared.quirks_mode(),
);
let map = &mut self.context.thread_local.selector_flags;
let resolving_element = self.element;
@ -518,17 +517,16 @@ where
self.rule_inclusion,
&mut applicable_declarations,
&mut matching_context,
&mut set_selector_flags
&mut set_selector_flags,
);
if applicable_declarations.is_empty() {
return None;
}
let rule_node = stylist.rule_tree().compute_rule_node(
&mut applicable_declarations,
&self.context.shared.guards
);
let rule_node = stylist
.rule_tree()
.compute_rule_node(&mut applicable_declarations, &self.context.shared.guards);
Some(rule_node)
}