style: Use Option::as_deref() in style code.

And drive-by simplify another function that was only doing
Option::clone().

Differential Revision: https://phabricator.services.mozilla.com/D92839
This commit is contained in:
Emilio Cobos Álvarez 2020-10-08 09:42:49 +00:00
parent 379fb984f1
commit 384fd59ad0
4 changed files with 10 additions and 16 deletions

View file

@ -472,7 +472,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
} }
fn default_namespace(&self) -> Option<Namespace> { fn default_namespace(&self) -> Option<Namespace> {
self.namespaces.default.as_ref().map(|ns| ns.clone()) self.namespaces.default.clone()
} }
fn namespace_for_prefix(&self, prefix: &Atom) -> Option<Namespace> { fn namespace_for_prefix(&self, prefix: &Atom) -> Option<Namespace> {

View file

@ -395,7 +395,7 @@ trait PrivateMatchMethods: TElement {
if context.shared.traversal_flags.for_animation_only() { if context.shared.traversal_flags.for_animation_only() {
self.handle_display_change_for_smil_if_needed( self.handle_display_change_for_smil_if_needed(
context, context,
old_values.as_ref().map(|v| &**v), old_values.as_deref(),
new_values, new_values,
restyle_hint, restyle_hint,
); );
@ -408,7 +408,7 @@ trait PrivateMatchMethods: TElement {
let mut tasks = UpdateAnimationsTasks::empty(); let mut tasks = UpdateAnimationsTasks::empty();
if self.needs_animations_update( if self.needs_animations_update(
context, context,
old_values.as_ref().map(|s| &**s), old_values.as_deref(),
new_values, new_values,
/* pseudo_element = */ None, /* pseudo_element = */ None,
) { ) {
@ -417,7 +417,7 @@ trait PrivateMatchMethods: TElement {
let before_change_style = if self.might_need_transitions_update( let before_change_style = if self.might_need_transitions_update(
context, context,
old_values.as_ref().map(|s| &**s), old_values.as_deref(),
new_values, new_values,
/* pseudo_element = */ None, /* pseudo_element = */ None,
) { ) {
@ -460,7 +460,7 @@ trait PrivateMatchMethods: TElement {
if important_rules_changed { if important_rules_changed {
tasks.insert(UpdateAnimationsTasks::CASCADE_RESULTS); tasks.insert(UpdateAnimationsTasks::CASCADE_RESULTS);
} }
if new_values.is_display_property_changed_from_none(old_values.as_ref().map(|s| &**s)) { if new_values.is_display_property_changed_from_none(old_values.as_deref()) {
tasks.insert(UpdateAnimationsTasks::DISPLAY_CHANGED_FROM_NONE); tasks.insert(UpdateAnimationsTasks::DISPLAY_CHANGED_FROM_NONE);
} }
} }
@ -638,14 +638,14 @@ trait PrivateMatchMethods: TElement {
// map because this call will do a RwLock::read(). // map because this call will do a RwLock::read().
let needs_animations_update = self.needs_animations_update( let needs_animations_update = self.needs_animations_update(
context, context,
old_values.as_ref().map(|s| &**s), old_values.as_deref(),
new_values, new_values,
pseudo_element, pseudo_element,
); );
let might_need_transitions_update = self.might_need_transitions_update( let might_need_transitions_update = self.might_need_transitions_update(
context, context,
old_values.as_ref().map(|s| &**s), old_values.as_deref(),
new_values, new_values,
pseudo_element, pseudo_element,
); );

View file

@ -2966,7 +2966,7 @@ impl ComputedValues {
/// Returns the visited style, if any. /// Returns the visited style, if any.
pub fn visited_style(&self) -> Option<<&ComputedValues> { pub fn visited_style(&self) -> Option<<&ComputedValues> {
self.visited_style.as_ref().map(|s| &**s) self.visited_style.as_deref()
} }
/// Returns the visited rules, if applicable. /// Returns the visited rules, if applicable.

View file

@ -351,10 +351,7 @@ where
rule_inclusion, rule_inclusion,
PseudoElementResolution::IfApplicable, PseudoElementResolution::IfApplicable,
) )
.resolve_primary_style( .resolve_primary_style(style.as_deref(), layout_parent_style.as_deref());
style.as_ref().map(|s| &**s),
layout_parent_style.as_ref().map(|s| &**s),
);
let is_display_contents = primary_style.style().is_display_contents(); let is_display_contents = primary_style.style().is_display_contents();
@ -373,10 +370,7 @@ where
rule_inclusion, rule_inclusion,
PseudoElementResolution::Force, PseudoElementResolution::Force,
) )
.resolve_style( .resolve_style(style.as_deref(), layout_parent_style.as_deref())
style.as_ref().map(|s| &**s),
layout_parent_style.as_ref().map(|s| &**s),
)
.into() .into()
} }