diff --git a/servo/components/style/rule_tree/core.rs b/servo/components/style/rule_tree/core.rs index 2c11868201a9..f3abef426dde 100644 --- a/servo/components/style/rule_tree/core.rs +++ b/servo/components/style/rule_tree/core.rs @@ -185,6 +185,9 @@ impl RuleTree { /// where it likely did not result from a rigorous performance analysis.) const RULE_TREE_GC_INTERVAL: usize = 300; +/// Used for some size assertions. +pub const RULE_NODE_SIZE: usize = std::mem::size_of::(); + /// A node in the rule tree. struct RuleNode { /// The root node. Only the root has no root pointer, for obvious reasons. diff --git a/servo/components/style/rule_tree/mod.rs b/servo/components/style/rule_tree/mod.rs index ab5273db7812..e50382255ca2 100644 --- a/servo/components/style/rule_tree/mod.rs +++ b/servo/components/style/rule_tree/mod.rs @@ -19,7 +19,7 @@ mod map; mod source; mod unsafe_box; -pub use self::core::{RuleTree, StrongRuleNode}; +pub use self::core::{RuleTree, StrongRuleNode, RULE_NODE_SIZE}; pub use self::level::{CascadeLevel, ShadowCascadeOrder}; pub use self::source::StyleSource; diff --git a/servo/ports/geckolib/tests/size_of.rs b/servo/ports/geckolib/tests/size_of.rs index c8f1727bd54b..d19522a2e222 100644 --- a/servo/ports/geckolib/tests/size_of.rs +++ b/servo/ports/geckolib/tests/size_of.rs @@ -8,7 +8,7 @@ use style::applicable_declarations::ApplicableDeclarationBlock; use style::data::{ElementData, ElementStyles}; use style::gecko::selector_parser::{self, SelectorImpl}; use style::properties::ComputedValues; -use style::rule_tree::{RuleNode, StrongRuleNode}; +use style::rule_tree::{RULE_NODE_SIZE, StrongRuleNode}; use style::servo_arc::Arc; use style::values::computed; use style::values::specified; @@ -53,7 +53,10 @@ size_of_test!( 16 ); -size_of_test!(test_size_of_rule_node, RuleNode, 80); +#[test] +fn test_size_of_rule_node() { + assert_eq!(RULE_NODE_SIZE, 80, "RuleNode size changed"); +} // This is huge, but we allocate it on the stack and then never move it, // we only pass `&mut SourcePropertyDeclaration` references around.