Eliminate RestyleResult.

The new incremental restyle algorithm will make traversal decisions in a more
centralized way.

MozReview-Commit-ID: GH6gFt4VUJO
This commit is contained in:
Bobby Holley 2016-10-28 15:18:03 -07:00
parent 71b9004d86
commit 1a5e2b4673
7 changed files with 52 additions and 63 deletions

View file

@ -10,7 +10,6 @@ use gecko::context::StandaloneStyleContext;
use gecko::wrapper::{GeckoElement, GeckoNode};
use std::mem;
use traversal::{DomTraversalContext, recalc_style_at};
use traversal::RestyleResult;
pub struct RecalcStyleOnly<'lc> {
context: StandaloneStyleContext<'lc>,
@ -30,14 +29,10 @@ impl<'lc, 'ln> DomTraversalContext<GeckoNode<'ln>> for RecalcStyleOnly<'lc> {
}
}
fn process_preorder(&self, node: GeckoNode<'ln>) -> RestyleResult {
if node.is_text_node() {
// Text nodes don't have children, so save the traversal algorithm
// the trouble of iterating the children.
RestyleResult::Stop
} else {
fn process_preorder(&self, node: GeckoNode<'ln>) {
if node.is_element() {
let el = node.as_element().unwrap();
recalc_style_at::<_, _, Self>(&self.context, self.root, el)
recalc_style_at::<_, _, Self>(&self.context, self.root, el);
}
}
@ -48,7 +43,11 @@ impl<'lc, 'ln> DomTraversalContext<GeckoNode<'ln>> for RecalcStyleOnly<'lc> {
/// We don't use the post-order traversal for anything.
fn needs_postorder_traversal(&self) -> bool { false }
fn should_traverse_child(_parent: GeckoElement<'ln>, child: GeckoNode<'ln>) -> bool {
fn should_traverse_child(parent: GeckoElement<'ln>, child: GeckoNode<'ln>) -> bool {
if parent.is_display_none() {
return false;
}
match child.as_element() {
Some(el) => el.styling_mode() != StylingMode::Stop,
None => false, // Gecko restyle doesn't need to traverse text nodes.