Add an is_text_node to LayoutNode, so that we don't need to implement type_id for the style system.

This commit is contained in:
Bobby Holley 2015-12-15 20:37:53 -08:00
parent 6637626e02
commit e55a56d757
2 changed files with 45 additions and 40 deletions

View file

@ -93,6 +93,11 @@ pub trait LayoutNode<'ln> : Sized + Copy + Clone {
/// Returns the type ID of this node.
fn type_id(&self) -> NodeTypeId;
/// Returns whether this is a text node. It turns out that this is all the style system cares
/// about, and thus obviates the need to compute the full type id, which would be expensive in
/// Gecko.
fn is_text_node(&self) -> bool;
fn is_element(&self) -> bool;
fn dump(self);
@ -304,6 +309,10 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
}
}
fn is_text_node(&self) -> bool {
self.type_id() == NodeTypeId::CharacterData(CharacterDataTypeId::Text)
}
fn is_element(&self) -> bool {
unsafe {
self.node.is_element_for_layout()