mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
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:
parent
1470d5b174
commit
6d67525172
10 changed files with 120 additions and 48 deletions
|
@ -46,7 +46,19 @@ impl OpaqueNode {
|
|||
}
|
||||
|
||||
pub trait TRestyleDamage : BitOr<Output=Self> + Copy {
|
||||
fn compute(old: Option<&Arc<ComputedValues>>, new: &Arc<ComputedValues>) -> Self;
|
||||
/// The source for our current computed values in the cascade. This is a
|
||||
/// ComputedValues in Servo and a StyleContext in Gecko.
|
||||
///
|
||||
/// This is needed because Gecko has a few optimisations for the calculation
|
||||
/// of the difference depending on which values have been used during
|
||||
/// layout.
|
||||
///
|
||||
/// This should be obtained via TNode::existing_style_for_restyle_damage
|
||||
type PreExistingComputedValues;
|
||||
|
||||
fn compute(old: Option<&Self::PreExistingComputedValues>,
|
||||
new: &Arc<ComputedValues>) -> Self;
|
||||
|
||||
fn rebuild_and_reflow() -> Self;
|
||||
}
|
||||
|
||||
|
@ -159,6 +171,13 @@ pub trait TNode : Sized + Copy + Clone {
|
|||
fn unstyle(self) {
|
||||
self.mutate_data().unwrap().style = None;
|
||||
}
|
||||
|
||||
/// XXX: It's a bit unfortunate we need to pass the current computed values
|
||||
/// as an argument here, but otherwise Servo would crash due to double
|
||||
/// borrows to return it.
|
||||
fn existing_style_for_restyle_damage<'a>(&'a self,
|
||||
current_computed_values: Option<&'a Arc<ComputedValues>>)
|
||||
-> Option<&'a <Self::ConcreteRestyleDamage as TRestyleDamage>::PreExistingComputedValues>;
|
||||
}
|
||||
|
||||
pub trait TDocument : Sized + Copy + Clone {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue