Struct style::rule_tree::RuleTree

source ·
pub struct RuleTree {
    root: StrongRuleNode,
}
Expand description

The rule tree, the structure servo uses to preserve the results of selector matching.

This is organized as a tree of rules. When a node matches a set of rules, they’re inserted in order in the tree, starting with the less specific one.

When a rule is inserted in the tree, other elements may share the path up to a given rule. If that’s the case, we don’t duplicate child nodes, but share them.

When the rule node refcount drops to zero, it doesn’t get freed. It gets instead put into a free list, and it is potentially GC’d after a while.

That way, a rule node that represents a likely-to-match-again rule (like a :hover rule) can be reused if we haven’t GC’d it yet.

Fields§

§root: StrongRuleNode

Implementations§

source§

impl RuleTree

source

pub fn new() -> Self

Construct a new rule tree.

source

pub fn root(&self) -> &StrongRuleNode

Get the root rule node.

source

pub fn gc(&self)

This can only be called when no other threads is accessing this tree.

source

pub fn maybe_gc(&self)

This can only be called when no other threads is accessing this tree.

source

fn maybe_dump_stats(&self)

source

unsafe fn swap_free_list_and_gc(&self, ptr: *mut RuleNode)

Steals the free list and drops its contents.

source§

impl RuleTree

source

fn dump<W: Write>(&self, guards: &StylesheetGuards<'_>, writer: &mut W)

source

pub fn dump_stdout(&self, guards: &StylesheetGuards<'_>)

Dump the rule tree to stdout.

source

pub fn insert_ordered_rules_with_important<'a, I>( &self, iter: I, guards: &StylesheetGuards<'_>, ) -> StrongRuleNode
where I: Iterator<Item = (StyleSource, CascadePriority)>,

Inserts the given rules, that must be in proper order by specifity, and returns the corresponding rule node representing the last inserted one.

!important rules are detected and inserted into the appropriate position in the rule tree. This allows selector matching to ignore importance, while still maintaining the appropriate cascade order in the rule tree.

source

pub fn compute_rule_node( &self, applicable_declarations: &mut ApplicableDeclarationList, guards: &StylesheetGuards<'_>, ) -> StrongRuleNode

Given a list of applicable declarations, insert the rules and return the corresponding rule node.

source

pub fn insert_ordered_rules<'a, I>(&self, iter: I) -> StrongRuleNode
where I: Iterator<Item = (StyleSource, CascadePriority)>,

Insert the given rules, that must be in proper order by specifity, and return the corresponding rule node representing the last inserted one.

source

fn insert_ordered_rules_from<'a, I>( &self, from: StrongRuleNode, iter: I, ) -> StrongRuleNode
where I: Iterator<Item = (StyleSource, CascadePriority)>,

source

pub fn update_rule_at_level( &self, level: CascadeLevel, layer_order: LayerOrder, pdb: Option<ArcBorrow<'_, Locked<PropertyDeclarationBlock>>>, path: &StrongRuleNode, guards: &StylesheetGuards<'_>, important_rules_changed: &mut bool, ) -> Option<StrongRuleNode>

Replaces a rule in a given level (if present) for another rule.

Returns the resulting node that represents the new path, or None if the old path is still valid.

source

pub fn remove_transition_rule_if_applicable( &self, path: &StrongRuleNode, ) -> StrongRuleNode

Returns new rule nodes without Transitions level rule.

source

pub fn remove_animation_rules(&self, path: &StrongRuleNode) -> StrongRuleNode

Returns new rule node without rules from declarative animations.

Trait Implementations§

source§

impl Debug for RuleTree

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for RuleTree

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl MallocSizeOf for RuleTree

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T