Skip to content

Commit

Permalink
style: Add TNode::children_and_traversal_children_might_differ.
Browse files Browse the repository at this point in the history
This will be used to optimize out traversing the real DOM children when
propagating restyle hints.
  • Loading branch information
heycam committed Jun 9, 2017
1 parent c533097 commit 719709f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/script/layout_wrapper.rs
Expand Up @@ -185,6 +185,12 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
self.children()
}

fn children_and_traversal_children_might_differ(&self) -> bool {
// Servo doesn't have to worry about nodes being rearranged in the
// flattened tree like Gecko does (for XBL and Shadow DOM). Yet.
false
}

fn opaque(&self) -> OpaqueNode {
unsafe { self.get_jsmanaged().opaque() }
}
Expand Down
4 changes: 4 additions & 0 deletions components/style/dom.rs
Expand Up @@ -126,6 +126,10 @@ pub trait TNode : Sized + Copy + Clone + Debug + NodeInfo {
/// Get this node's children from the perspective of a restyle traversal.
fn traversal_children(&self) -> LayoutIterator<Self::ConcreteChildrenIterator>;

/// Returns whether `children()` and `traversal_children()` might return
/// iterators over different nodes.
fn children_and_traversal_children_might_differ(&self) -> bool;

/// Converts self into an `OpaqueNode`.
fn opaque(&self) -> OpaqueNode;

Expand Down
5 changes: 5 additions & 0 deletions components/style/gecko/wrapper.rs
Expand Up @@ -34,6 +34,7 @@ use gecko_bindings::bindings::{Gecko_IsRootElement, Gecko_MatchesElement, Gecko_
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use gecko_bindings::bindings::Gecko_ClassOrClassList;
use gecko_bindings::bindings::Gecko_ElementHasAnimations;
use gecko_bindings::bindings::Gecko_ElementHasBindingWithAnonymousContent;
use gecko_bindings::bindings::Gecko_ElementHasCSSAnimations;
use gecko_bindings::bindings::Gecko_ElementHasCSSTransitions;
use gecko_bindings::bindings::Gecko_GetActiveLinkAttrDeclarationBlock;
Expand Down Expand Up @@ -271,6 +272,10 @@ impl<'ln> TNode for GeckoNode<'ln> {
}
}

fn children_and_traversal_children_might_differ(&self) -> bool {
self.as_element().map_or(false, |e| unsafe { Gecko_ElementHasBindingWithAnonymousContent(e.0) })
}

fn opaque(&self) -> OpaqueNode {
let ptr: usize = self.0 as *const _ as usize;
OpaqueNode(ptr)
Expand Down

0 comments on commit 719709f

Please sign in to comment.