aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko/restyle_damage.rs
diff options
context:
space:
mode:
authorCameron McCormack <cam@mcc.id.au>2017-07-25 11:11:47 +0800
committerCameron McCormack <cam@mcc.id.au>2017-07-25 15:50:00 +0800
commite36b4340e1220e666e325dfa982ec74ce9c75602 (patch)
tree5e8943aee81acfc36cd87bed32f19bee27bfc7d2 /components/style/gecko/restyle_damage.rs
parentbf16b146e8edbf3e3513188fe495354546160988 (diff)
downloadservo-e36b4340e1220e666e325dfa982ec74ce9c75602.tar.gz
servo-e36b4340e1220e666e325dfa982ec74ce9c75602.zip
style: Ensure we generate a ReconstructFrame hint when -moz-binding changes on a display:none root.
Diffstat (limited to 'components/style/gecko/restyle_damage.rs')
-rw-r--r--components/style/gecko/restyle_damage.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/components/style/gecko/restyle_damage.rs b/components/style/gecko/restyle_damage.rs
index 7d0c29c232f..b0f60663067 100644
--- a/components/style/gecko/restyle_damage.rs
+++ b/components/style/gecko/restyle_damage.rs
@@ -6,7 +6,7 @@
use gecko_bindings::bindings;
use gecko_bindings::structs;
-use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
+use gecko_bindings::structs::{nsChangeHint, nsStyleContext, nsStyleStructID};
use matching::{StyleChange, StyleDifference};
use properties::ComputedValues;
use servo_arc::Arc;
@@ -62,6 +62,34 @@ impl GeckoRestyleDamage {
StyleDifference::new(GeckoRestyleDamage(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(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