style: Pass a &ComputedValues (aka ServoStyleContext*) to Gecko_CalcStyleDifference.
draft
style: Pass a &ComputedValues (aka ServoStyleContext*) to Gecko_CalcStyleDifference.
MozReview-Commit-ID: J5xUn1nEqOB
--- a/servo/components/style/gecko/restyle_damage.rs
+++ b/servo/components/style/gecko/restyle_damage.rs
@@ -50,17 +50,17 @@ impl GeckoRestyleDamage {
source: &nsStyleContext,
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,
- &new_style,
+ new_style.as_style_context(),
&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/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -132,16 +132,20 @@ impl ComputedValues {
let atom = (self.0)._base.mPseudoTag.raw::<structs::nsIAtom>();
if atom.is_null() {
return None;
}
let atom = Atom::from(atom);
PseudoElement::from_atom(&atom)
}
+
+ pub fn as_style_context(&self) -> &::gecko_bindings::structs::mozilla::ServoStyleContext {
+ &self.0
+ }
}
impl Drop for ComputedValues {
fn drop(&mut self) {
unsafe {
bindings::Gecko_ServoStyleContext_Destroy(&mut self.0);
}
}