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

@ -44,21 +44,28 @@ bitflags! {
}
impl TRestyleDamage for RestyleDamage {
fn compute(old: Option<&Arc<ServoComputedValues>>, new: &Arc<ServoComputedValues>) ->
RestyleDamage { compute_damage(old, new) }
/// For Servo the style source is always the computed values.
type PreExistingComputedValues = Arc<ServoComputedValues>;
/// Returns a bitmask that represents a flow that needs to be rebuilt and reflowed.
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.
///
/// Use this instead of `RestyleDamage::all()` because `RestyleDamage::all()` will result in
/// unnecessary sequential resolution of generated content.
/// Use this instead of `RestyleDamage::all()` because
/// `RestyleDamage::all()` will result in unnecessary sequential resolution
/// of generated content.
fn rebuild_and_reflow() -> RestyleDamage {
REPAINT | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW | RECONSTRUCT_FLOW
}
}
impl RestyleDamage {
/// Supposing a flow has the given `position` property and this damage, returns the damage that
/// we should add to the *parent* of this flow.
/// Supposing a flow has the given `position` property and this damage,
/// returns the damage that we should add to the *parent* of this flow.
pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> RestyleDamage {
if child_is_absolutely_positioned {
self & (REPAINT | STORE_OVERFLOW | REFLOW_OUT_OF_FLOW | RESOLVE_GENERATED_CONTENT)