mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Prevent cousin sharing if we haven't restyled the parents.
This "fixes" bug 1381821 by disabling the optimization in the cases we can't prove this is correct. Bug 1387116 tracks fixing the optimization to apply more broadly. Bug: 1381821 Reviewed-by: bz MozReview-Commit-ID: COKdmHHokGx
This commit is contained in:
parent
48ea7a29e0
commit
2940270a50
1 changed files with 25 additions and 4 deletions
|
@ -19,17 +19,38 @@ use sharing::{StyleSharingCandidate, StyleSharingTarget};
|
||||||
///
|
///
|
||||||
/// This is used to know whether we can share style across cousins (if the two
|
/// This is used to know whether we can share style across cousins (if the two
|
||||||
/// parents have the same style).
|
/// parents have the same style).
|
||||||
|
///
|
||||||
|
/// We can only prove that they have the same class list, state, etc if they've
|
||||||
|
/// been restyled at the same time, otherwise the invalidation pass could make
|
||||||
|
/// them keep the same computed values even though now we wouldn't be able to
|
||||||
|
/// prove we match the same selectors.
|
||||||
pub fn same_computed_values<E>(first: Option<E>, second: Option<E>) -> bool
|
pub fn same_computed_values<E>(first: Option<E>, second: Option<E>) -> bool
|
||||||
where E: TElement,
|
where E: TElement,
|
||||||
{
|
{
|
||||||
let (a, b) = match (first, second) {
|
let (first, second) = match (first, second) {
|
||||||
(Some(f), Some(s)) => (f, s),
|
(Some(f), Some(s)) => (f, s),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let eq = Arc::ptr_eq(a.borrow_data().unwrap().styles.primary(),
|
debug_assert_ne!(first, second);
|
||||||
b.borrow_data().unwrap().styles.primary());
|
|
||||||
eq
|
let first_data = first.borrow_data().unwrap();
|
||||||
|
let second_data = second.borrow_data().unwrap();
|
||||||
|
|
||||||
|
// FIXME(emilio): This check effectively disables cousin style sharing
|
||||||
|
// on the initial style.
|
||||||
|
//
|
||||||
|
// This is pretty bad, se the discussion in bug 1381821 for mor details.
|
||||||
|
//
|
||||||
|
// Bug 1387116 tracks fixing this, and various solutions are listed there.
|
||||||
|
if !first_data.restyle.is_restyle() || !second_data.restyle.is_restyle() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let same_computed_values =
|
||||||
|
Arc::ptr_eq(first_data.styles.primary(), second_data.styles.primary());
|
||||||
|
|
||||||
|
same_computed_values
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether two elements have the same same style attribute (by pointer identity).
|
/// Whether two elements have the same same style attribute (by pointer identity).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue