stylo: Remove a lot of the restyle damage related complexity.

The only reason why we had the `existing_style_for_style_damage` bit is to apply
some optimizations that we don't have anymore.

I still want to reintroduce a few of them, at least for the non-eager
pseudo-element case... But I think I won't need this at all.

This allows us to remove a fair amount of Gecko code too.
This commit is contained in:
Emilio Cobos Álvarez 2017-08-19 17:42:18 +02:00
parent c1b196b7cb
commit 0f37b209cb
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
10 changed files with 76 additions and 199 deletions

View file

@ -6,7 +6,7 @@
use gecko_bindings::bindings;
use gecko_bindings::structs;
use gecko_bindings::structs::{nsChangeHint, nsStyleContext, nsStyleStructID};
use gecko_bindings::structs::nsChangeHint;
use matching::{StyleChange, StyleDifference};
use properties::ComputedValues;
use std::ops::{BitAnd, BitOr, BitOrAssign, Not};
@ -46,49 +46,22 @@ impl GeckoRestyleDamage {
/// structs, so they effectively only diff structs that have ever been
/// accessed from layout.
pub fn compute_style_difference(
source: &nsStyleContext,
old_style: &ComputedValues,
new_style: &ComputedValues,
) -> StyleDifference {
let mut any_style_changed: bool = false;
let hint = unsafe {
bindings::Gecko_CalcStyleDifference(old_style,
new_style,
source.mBits,
&mut any_style_changed)
bindings::Gecko_CalcStyleDifference(
old_style,
new_style,
structs::NS_STYLE_INHERIT_MASK as u64,
&mut any_style_changed
)
};
let change = if any_style_changed { StyleChange::Changed } else { StyleChange::Unchanged };
StyleDifference::new(GeckoRestyleDamage(nsChangeHint(hint)), change)
}
/// Computes the `StyleDifference` between the two `ComputedValues` objects
/// for the case where the old and new style are both `display: none`.
///
/// In general we don't need to generate damage for such elements, but we
/// do need to generate a frame reconstruction for `-moz-binding` changes,
/// so that we can start loading the new binding.
pub fn compute_undisplayed_style_difference(
old_style: &ComputedValues,
new_style: &ComputedValues,
) -> StyleDifference {
let mut any_style_changed: bool = false;
// Just compute the Display struct's difference.
let display_struct_bit = 1 << (nsStyleStructID::eStyleStruct_Display as u32);
let hint = unsafe {
bindings::Gecko_CalcStyleDifference(old_style,
new_style,
display_struct_bit,
&mut any_style_changed)
};
// Only pay attention to a reconstruct change hint.
let damage = GeckoRestyleDamage(nsChangeHint(hint)) & Self::reconstruct();
let change = if damage.is_empty() { StyleChange::Changed } else { StyleChange::Unchanged };
StyleDifference::new(damage, change)
}
/// Returns true if this restyle damage contains all the damage of |other|.
pub fn contains(self, other: Self) -> bool {
self & other == other