Stop generating flows under display: none.

Because this is a bottom-up traversal it can generates flows and throw them away. To prevent that, this cascades an internal `-servo-under-display-none` property and then checks that during flow construction.  Fixes #1536.
This commit is contained in:
Matt Brubeck 2016-05-25 10:48:09 -07:00
parent 116faa7617
commit 5c09e26e55
5 changed files with 50 additions and 10 deletions

View file

@ -1501,7 +1501,15 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
//
// TODO: This should actually consult the table in that section to get the
// final computed value for 'display'.
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode) -> bool {
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode) {
node.insert_flags(HAS_NEWLY_CONSTRUCTED_FLOW);
// Bail out if this node has an ancestor with display: none.
if node.style(self.style_context()).get_inheritedbox()._servo_under_display_none.0 {
self.set_flow_construction_result(node, ConstructionResult::None);
return;
}
// Get the `display` property for this node, and determine whether this node is floated.
let (display, float, positioning) = match node.type_id() {
None => {
@ -1542,12 +1550,8 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
// Switch on display and floatedness.
match (display, float, positioning) {
// `display: none` contributes no flow construction result. Nuke the flow construction
// results of children.
// `display: none` contributes no flow construction result.
(display::T::none, _, _) => {
for child in node.children() {
self.set_flow_construction_result(&child, ConstructionResult::None);
}
self.set_flow_construction_result(node, ConstructionResult::None);
}
@ -1654,9 +1658,6 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
self.set_flow_construction_result(node, construction_result)
}
}
node.insert_flags(HAS_NEWLY_CONSTRUCTED_FLOW);
true
}
}

View file

@ -178,6 +178,7 @@ pub fn compute_damage(old: Option<&Arc<ServoComputedValues>>, new: &ServoCompute
], [
get_box.float, get_box.display, get_box.position, get_counters.content,
get_counters.counter_reset, get_counters.counter_increment,
get_inheritedbox._servo_under_display_none,
get_list.quotes, get_list.list_style_type,
// If these text or font properties change, we need to reconstruct the flow so that

View file

@ -72,7 +72,7 @@ impl<'lc, 'ln> DomTraversalContext<ServoLayoutNode<'ln>> for RecalcStyleAndConst
/// A bottom-up, parallelizable traversal.
pub trait PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> {
/// The operation to perform. Return true to continue or false to stop.
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode) -> bool;
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode);
}
/// The flow construction traversal, which builds flows for styled nodes.