aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/servo/restyle_damage.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/style/servo/restyle_damage.rs')
-rw-r--r--components/style/servo/restyle_damage.rs144
1 files changed, 93 insertions, 51 deletions
diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs
index 9b8a16353bd..da682119eaf 100644
--- a/components/style/servo/restyle_damage.rs
+++ b/components/style/servo/restyle_damage.rs
@@ -61,10 +61,7 @@ malloc_size_of_is_0!(ServoRestyleDamage);
impl ServoRestyleDamage {
/// Compute the `StyleDifference` (including the appropriate restyle damage)
/// for a given style change between `old` and `new`.
- pub fn compute_style_difference(
- old: &ComputedValues,
- new: &ComputedValues,
- ) -> StyleDifference {
+ pub fn compute_style_difference(old: &ComputedValues, new: &ComputedValues) -> StyleDifference {
let damage = compute_damage(old, new);
let change = if damage.is_empty() {
StyleChange::Unchanged
@@ -84,9 +81,9 @@ impl ServoRestyleDamage {
/// RECONSTRUCT_FLOW imply everything else?
pub fn rebuild_and_reflow() -> ServoRestyleDamage {
ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION |
- ServoRestyleDamage::STORE_OVERFLOW | ServoRestyleDamage::BUBBLE_ISIZES |
- ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW |
- ServoRestyleDamage::RECONSTRUCT_FLOW
+ ServoRestyleDamage::STORE_OVERFLOW | ServoRestyleDamage::BUBBLE_ISIZES |
+ ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::REFLOW |
+ ServoRestyleDamage::RECONSTRUCT_FLOW
}
/// Returns a bitmask indicating that the frame needs to be reconstructed.
@@ -99,28 +96,35 @@ impl ServoRestyleDamage {
pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> ServoRestyleDamage {
if child_is_absolutely_positioned {
self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION |
- ServoRestyleDamage::STORE_OVERFLOW | ServoRestyleDamage::REFLOW_OUT_OF_FLOW |
- ServoRestyleDamage::RESOLVE_GENERATED_CONTENT)
+ ServoRestyleDamage::STORE_OVERFLOW |
+ ServoRestyleDamage::REFLOW_OUT_OF_FLOW |
+ ServoRestyleDamage::RESOLVE_GENERATED_CONTENT)
} else {
self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION |
- ServoRestyleDamage::STORE_OVERFLOW | ServoRestyleDamage::REFLOW |
- ServoRestyleDamage::REFLOW_OUT_OF_FLOW | ServoRestyleDamage::RESOLVE_GENERATED_CONTENT)
+ ServoRestyleDamage::STORE_OVERFLOW |
+ ServoRestyleDamage::REFLOW |
+ ServoRestyleDamage::REFLOW_OUT_OF_FLOW |
+ ServoRestyleDamage::RESOLVE_GENERATED_CONTENT)
}
}
/// Supposing the *parent* of a flow with the given `position` property has
/// this damage, returns the damage that we should add to this flow.
- pub fn damage_for_child(self,
- parent_is_absolutely_positioned: bool,
- child_is_absolutely_positioned: bool)
- -> ServoRestyleDamage {
- match (parent_is_absolutely_positioned, child_is_absolutely_positioned) {
+ pub fn damage_for_child(
+ self,
+ parent_is_absolutely_positioned: bool,
+ child_is_absolutely_positioned: bool,
+ ) -> ServoRestyleDamage {
+ match (
+ parent_is_absolutely_positioned,
+ child_is_absolutely_positioned,
+ ) {
(false, true) => {
// Absolute children are out-of-flow and therefore insulated from changes.
//
// FIXME(pcwalton): Au contraire, if the containing block dimensions change!
self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION)
- }
+ },
(true, false) => {
// Changing the position of an absolutely-positioned block requires us to reflow
// its kids.
@@ -129,11 +133,12 @@ impl ServoRestyleDamage {
} else {
self
}
- }
+ },
_ => {
// TODO(pcwalton): Take floatedness into account.
- self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION | ServoRestyleDamage::REFLOW)
- }
+ self & (ServoRestyleDamage::REPAINT | ServoRestyleDamage::REPOSITION |
+ ServoRestyleDamage::REFLOW)
+ },
}
}
}
@@ -148,20 +153,25 @@ impl fmt::Display for ServoRestyleDamage {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let mut first_elem = true;
- let to_iter =
- [ (ServoRestyleDamage::REPAINT, "Repaint")
- , (ServoRestyleDamage::REPOSITION, "Reposition")
- , (ServoRestyleDamage::STORE_OVERFLOW, "StoreOverflow")
- , (ServoRestyleDamage::BUBBLE_ISIZES, "BubbleISizes")
- , (ServoRestyleDamage::REFLOW_OUT_OF_FLOW, "ReflowOutOfFlow")
- , (ServoRestyleDamage::REFLOW, "Reflow")
- , (ServoRestyleDamage::RESOLVE_GENERATED_CONTENT, "ResolveGeneratedContent")
- , (ServoRestyleDamage::RECONSTRUCT_FLOW, "ReconstructFlow")
- ];
+ let to_iter = [
+ (ServoRestyleDamage::REPAINT, "Repaint"),
+ (ServoRestyleDamage::REPOSITION, "Reposition"),
+ (ServoRestyleDamage::STORE_OVERFLOW, "StoreOverflow"),
+ (ServoRestyleDamage::BUBBLE_ISIZES, "BubbleISizes"),
+ (ServoRestyleDamage::REFLOW_OUT_OF_FLOW, "ReflowOutOfFlow"),
+ (ServoRestyleDamage::REFLOW, "Reflow"),
+ (
+ ServoRestyleDamage::RESOLVE_GENERATED_CONTENT,
+ "ResolveGeneratedContent",
+ ),
+ (ServoRestyleDamage::RECONSTRUCT_FLOW, "ReconstructFlow"),
+ ];
for &(damage, damage_str) in &to_iter {
if self.contains(damage) {
- if !first_elem { write!(f, " | ")?; }
+ if !first_elem {
+ write!(f, " | ")?;
+ }
write!(f, "{}", damage_str)?;
first_elem = false;
}
@@ -181,27 +191,59 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
// This should check every CSS property, as enumerated in the fields of
// http://doc.servo.org/style/properties/struct.ComputedValues.html
- restyle_damage_rebuild_and_reflow!(old, new, damage,
- [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
- ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,
- ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW,
- ServoRestyleDamage::RECONSTRUCT_FLOW]) ||
+ restyle_damage_rebuild_and_reflow!(
+ old,
+ new,
+ damage,
+ [
+ ServoRestyleDamage::REPAINT,
+ ServoRestyleDamage::REPOSITION,
+ ServoRestyleDamage::STORE_OVERFLOW,
+ ServoRestyleDamage::BUBBLE_ISIZES,
+ ServoRestyleDamage::REFLOW_OUT_OF_FLOW,
+ ServoRestyleDamage::REFLOW,
+ ServoRestyleDamage::RECONSTRUCT_FLOW
+ ]
+ ) ||
(new.get_box().display == Display::Inline &&
- restyle_damage_rebuild_and_reflow_inline!(old, new, damage,
- [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
- ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,
- ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW,
- ServoRestyleDamage::RECONSTRUCT_FLOW])) ||
- restyle_damage_reflow!(old, new, damage,
- [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
- ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,
- ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW]) ||
- restyle_damage_reflow_out_of_flow!(old, new, damage,
- [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
- ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::REFLOW_OUT_OF_FLOW]) ||
- restyle_damage_repaint!(old, new, damage,
- [ServoRestyleDamage::REPAINT]);
-
+ restyle_damage_rebuild_and_reflow_inline!(
+ old,
+ new,
+ damage,
+ [
+ ServoRestyleDamage::REPAINT,
+ ServoRestyleDamage::REPOSITION,
+ ServoRestyleDamage::STORE_OVERFLOW,
+ ServoRestyleDamage::BUBBLE_ISIZES,
+ ServoRestyleDamage::REFLOW_OUT_OF_FLOW,
+ ServoRestyleDamage::REFLOW,
+ ServoRestyleDamage::RECONSTRUCT_FLOW
+ ]
+ )) ||
+ restyle_damage_reflow!(
+ old,
+ new,
+ damage,
+ [
+ ServoRestyleDamage::REPAINT,
+ ServoRestyleDamage::REPOSITION,
+ ServoRestyleDamage::STORE_OVERFLOW,
+ ServoRestyleDamage::BUBBLE_ISIZES,
+ ServoRestyleDamage::REFLOW_OUT_OF_FLOW,
+ ServoRestyleDamage::REFLOW
+ ]
+ ) ||
+ restyle_damage_reflow_out_of_flow!(
+ old,
+ new,
+ damage,
+ [
+ ServoRestyleDamage::REPAINT,
+ ServoRestyleDamage::REPOSITION,
+ ServoRestyleDamage::STORE_OVERFLOW,
+ ServoRestyleDamage::REFLOW_OUT_OF_FLOW
+ ]
+ ) || restyle_damage_repaint!(old, new, damage, [ServoRestyleDamage::REPAINT]);
// Paint worklets may depend on custom properties,
// so if they have changed we should repaint.