style: Make RuleTree::root return a reference instead of a strong pointer.

There's no reason it wasn't done before.

MozReview-Commit-ID: G0lMLWmfHbS
This commit is contained in:
Emilio Cobos Álvarez 2017-07-09 21:02:21 +02:00
parent cc94a8b7cb
commit fcf85e4658
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 37 additions and 48 deletions

View file

@ -150,8 +150,8 @@ impl RuleTree {
}
/// Get the root rule node.
pub fn root(&self) -> StrongRuleNode {
self.root.clone()
pub fn root(&self) -> &StrongRuleNode {
&self.root
}
fn dump<W: Write>(&self, guards: &StylesheetGuards, writer: &mut W) {
@ -171,11 +171,13 @@ impl RuleTree {
/// !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.
pub fn insert_ordered_rules_with_important<'a, I>(&self,
iter: I,
guards: &StylesheetGuards)
-> StrongRuleNode
where I: Iterator<Item=(StyleSource, CascadeLevel)>,
pub fn insert_ordered_rules_with_important<'a, I>(
&self,
iter: I,
guards: &StylesheetGuards
) -> StrongRuleNode
where
I: Iterator<Item=(StyleSource, CascadeLevel)>,
{
use self::CascadeLevel::*;
let mut current = self.root.clone();
@ -257,11 +259,11 @@ impl RuleTree {
/// Given a list of applicable declarations, insert the rules and return the
/// corresponding rule node.
pub fn compute_rule_node(&self,
applicable_declarations: &mut ApplicableDeclarationList,
guards: &StylesheetGuards)
-> StrongRuleNode
{
pub fn compute_rule_node(
&self,
applicable_declarations: &mut ApplicableDeclarationList,
guards: &StylesheetGuards
) -> StrongRuleNode {
let rules = applicable_declarations.drain().map(|d| d.order_and_level());
let rule_node = self.insert_ordered_rules_with_important(rules, guards);
rule_node