style: Pass old ComputedValues and old cached struct bits to Gecko_CalcStyleDifference.
draft
style: Pass old ComputedValues and old cached struct bits to Gecko_CalcStyleDifference.
MozReview-Commit-ID: 94fuzB6lHd8
--- a/servo/components/style/gecko/restyle_damage.rs
+++ b/servo/components/style/gecko/restyle_damage.rs
@@ -43,24 +43,24 @@ impl GeckoRestyleDamage {
/// (in the form of `ComputedValues`).
///
/// Note that we could in theory just get two `ComputedValues` here and diff
/// them, but Gecko has an interesting optimization when they mark accessed
/// structs, so they effectively only diff structs that have ever been
/// accessed from layout.
pub fn compute_style_difference(
source: &nsStyleContext,
- new_style: &Arc<ComputedValues>
+ old_style: &ComputedValues,
+ new_style: &Arc<ComputedValues>,
) -> StyleDifference {
- // TODO(emilio): Const-ify this?
- let context = source as *const nsStyleContext as *mut nsStyleContext;
let mut any_style_changed: bool = false;
let hint = unsafe {
- bindings::Gecko_CalcStyleDifference(context,
+ bindings::Gecko_CalcStyleDifference(old_style.as_style_context(),
new_style.as_style_context(),
+ source.mBits,
&mut any_style_changed)
};
let change = if any_style_changed { StyleChange::Changed } else { StyleChange::Unchanged };
StyleDifference::new(GeckoRestyleDamage(hint), change)
}
/// Returns true if this restyle damage contains all the damage of |other|.
pub fn contains(self, other: Self) -> bool {
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -763,17 +763,17 @@ pub trait MatchMethods : TElement {
fn compute_style_difference(
&self,
old_values: &ComputedValues,
new_values: &Arc<ComputedValues>,
pseudo: Option<&PseudoElement>
) -> StyleDifference {
debug_assert!(pseudo.map_or(true, |p| p.is_eager()));
if let Some(source) = self.existing_style_for_restyle_damage(old_values, pseudo) {
- return RestyleDamage::compute_style_difference(source, new_values)
+ return RestyleDamage::compute_style_difference(source, old_values, new_values)
}
let new_display = new_values.get_box().clone_display();
let old_display = old_values.get_box().clone_display();
let new_style_is_display_none = new_display == display::T::none;
let old_style_is_display_none = old_display == display::T::none;