Bug 1907320 - Allow sharing styles that specify transitions / animations. r=firefox-style-system-reviewers,layout-reviewers,boris

Most styles that specify transitions don't actually have a transition
running at the very same time, and we can check for that in the cache
already.

We need to avoid reusing-by-rule-node for @starting-style rules, but
that's fine because that's effectively what already happened before this
change, due to the check we're removing (we only resolve @starting-style
when we're about to maybe-start a transition).

Differential Revision: https://phabricator.services.mozilla.com/D216286
This commit is contained in:
Emilio Cobos Álvarez 2024-07-11 21:28:38 +00:00
parent 29e26a6e38
commit 3ef1f8561f
3 changed files with 5 additions and 21 deletions

View File

@ -605,7 +605,6 @@ impl<E: TElement> StyleSharingCache<E> {
pub fn insert_if_possible(
&mut self,
element: &E,
style: &PrimaryStyle,
validation_data_holder: Option<&mut StyleSharingTarget<E>>,
dom_depth: usize,
shared_context: &SharedStyleContext,
@ -646,23 +645,6 @@ impl<E: TElement> StyleSharingCache<E> {
return;
}
// In addition to the above running animations check, we also need to
// check CSS animation and transition styles since it's possible that
// we are about to create CSS animations/transitions.
//
// These are things we don't check in the candidate match because they
// are either uncommon or expensive.
let ui_style = style.style().get_ui();
if ui_style.specifies_transitions() {
debug!("Failing to insert to the cache: transitions");
return;
}
if ui_style.specifies_animations() {
debug!("Failing to insert to the cache: animations");
return;
}
debug!(
"Inserting into cache: {:?} with parent {:?}",
element, parent
@ -791,7 +773,7 @@ impl<E: TElement> StyleSharingCache<E> {
return None;
}
if target.element.has_animations(shared_context) {
if target.element.has_animations(shared_context) || candidate.element.has_animations(shared_context) {
trace!("Miss: Has Animations");
return None;
}

View File

@ -236,6 +236,7 @@ where
},
parent_style,
layout_parent_style,
include_starting_style,
primary_results.has_starting_style,
)
}
@ -245,6 +246,7 @@ where
inputs: CascadeInputs,
parent_style: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
include_starting_style: IncludeStartingStyle,
may_have_starting_style: bool,
) -> PrimaryStyle {
// Before doing the cascade, check the sharing cache and see if we can
@ -252,6 +254,7 @@ where
let may_reuse = self.element.matches_user_and_content_rules() &&
parent_style.is_some() &&
inputs.rules.is_some() &&
include_starting_style == IncludeStartingStyle::No &&
// If this style was considered in any way for relative selector matching,
// we do not want to lose that fact by sharing a style with something that
// did not.
@ -413,6 +416,7 @@ where
inputs.primary,
parent_style,
layout_parent_style,
IncludeStartingStyle::No,
may_have_starting_style,
);

View File

@ -621,7 +621,6 @@ where
context.thread_local.sharing_cache.insert_if_possible(
&element,
&new_styles.primary,
Some(&mut target),
traversal_data.current_dom_depth,
&context.shared,
@ -682,7 +681,6 @@ where
if !new_styles.primary.reused_via_rule_node {
context.thread_local.sharing_cache.insert_if_possible(
&element,
&new_styles.primary,
None,
traversal_data.current_dom_depth,
&context.shared,