style: Refactor TRestyleDamage and TNode to accept/provide a "style source"

In the Gecko case, this style source would be the style context. In the servo
case, it will be always the computed values.

We could optimise this further in the case of stylo (from three FFI calls to
one) if we use an API of the form CalcAndStore(node, new_cv). But that would
imply borrowing the data twice from Servo (we also have borrow_data_unchecked
fwiw, but...).
This commit is contained in:
Emilio Cobos Álvarez 2016-07-29 14:17:56 -07:00
parent 1470d5b174
commit 6d67525172
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
10 changed files with 120 additions and 48 deletions

View file

@ -14,6 +14,7 @@ use script_traits::{AnimationState, LayoutMsg as ConstellationMsg};
use std::collections::HashMap;
use std::sync::mpsc::Receiver;
use style::animation::{Animation, update_style_for_animation};
use style::dom::TRestyleDamage;
use style::timer::Timer;
/// Processes any new animations that were discovered after style recalculation.
@ -130,10 +131,11 @@ pub fn recalc_style_for_animations(context: &SharedLayoutContext,
flow.mutate_fragments(&mut |fragment| {
if let Some(ref animations) = animations.get(&fragment.node) {
for animation in animations.iter() {
let old_style = fragment.style.clone();
update_style_for_animation(&context.style_context,
animation,
&mut fragment.style,
Some(&mut damage));
&mut fragment.style);
damage |= RestyleDamage::compute(Some(&old_style), &fragment.style);
}
}
});