stylo: Allow computing change hints during the traversal.

This commit is contained in:
Emilio Cobos Álvarez 2016-07-28 19:36:37 -07:00
parent 67ac81f440
commit 1470d5b174
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 55 additions and 21 deletions

View file

@ -44,7 +44,7 @@ bitflags! {
}
impl TRestyleDamage for RestyleDamage {
fn compute(old: Option<&Arc<ServoComputedValues>>, new: &ServoComputedValues) ->
fn compute(old: Option<&Arc<ServoComputedValues>>, new: &Arc<ServoComputedValues>) ->
RestyleDamage { compute_damage(old, new) }
/// Returns a bitmask that represents a flow that needs to be rebuilt and reflowed.
@ -143,7 +143,8 @@ macro_rules! add_if_not_equal(
})
);
fn compute_damage(old: Option<&Arc<ServoComputedValues>>, new: &ServoComputedValues) -> RestyleDamage {
fn compute_damage(old: Option<&Arc<ServoComputedValues>>, new: &Arc<ServoComputedValues>) -> RestyleDamage {
let new = &**new;
let old: &ServoComputedValues = match old {
None => return RestyleDamage::rebuild_and_reflow(),
Some(cv) => &**cv,

View file

@ -46,7 +46,7 @@ impl OpaqueNode {
}
pub trait TRestyleDamage : BitOr<Output=Self> + Copy {
fn compute(old: Option<&Arc<ComputedValues>>, new: &ComputedValues) -> Self;
fn compute(old: Option<&Arc<ComputedValues>>, new: &Arc<ComputedValues>) -> Self;
fn rebuild_and_reflow() -> Self;
}

View file

@ -13,7 +13,6 @@ pub struct ArcHelpers<GeckoType, ServoType> {
phantom2: PhantomData<ServoType>,
}
impl<GeckoType, ServoType> ArcHelpers<GeckoType, ServoType> {
pub fn with<F, Output>(raw: *mut GeckoType, cb: F) -> Output
where F: FnOnce(&Arc<ServoType>) -> Output {
@ -47,6 +46,10 @@ impl<GeckoType, ServoType> ArcHelpers<GeckoType, ServoType> {
unsafe { transmute(owned) }
}
pub unsafe fn borrow(borrowed: &Arc<ServoType>) -> *const &mut GeckoType {
transmute(borrowed)
}
pub unsafe fn addref(ptr: *mut GeckoType) {
Self::with(ptr, |arc| forget(arc.clone()));
}

View file

@ -443,7 +443,7 @@ trait PrivateMatchMethods: TNode
}
// Calculate style difference.
let damage = Self::ConcreteRestyleDamage::compute(style.map(|s| &*s), &*this_style);
let damage = Self::ConcreteRestyleDamage::compute(style.map(|s| &*s), &this_style);
// Cache the resolved style if it was cacheable.
if cacheable {
@ -587,7 +587,7 @@ pub trait ElementMatchMethods : TElement {
let node = self.as_node();
let style = &mut node.mutate_data().unwrap().style;
let damage = <<Self as TElement>::ConcreteNode as TNode>
::ConcreteRestyleDamage::compute((*style).as_ref(), &*shared_style);
::ConcreteRestyleDamage::compute((*style).as_ref(), &shared_style);
*style = Some(shared_style);
return StyleSharingResult::StyleWasShared(i, damage)
}
@ -676,7 +676,7 @@ pub trait MatchMethods : TNode {
let mut data = &mut *data_ref;
let cloned_parent_style = ComputedValues::style_for_child_text_node(parent_style.unwrap());
damage = Self::ConcreteRestyleDamage::compute(data.style.as_ref(),
&*cloned_parent_style);
&cloned_parent_style);
data.style = Some(cloned_parent_style);
} else {
damage = {

View file

@ -12,7 +12,6 @@ use selector_impl::SelectorImplExt;
use selectors::Element;
use selectors::bloom::BloomFilter;
use std::cell::RefCell;
use std::sync::Arc;
use tid::tid;
use util::opts;
use values::HasViewportPercentage;