mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Make StrongRuleNode::ensure_child take a StrongRuleNode for the root
This commit is contained in:
parent
37c70609f9
commit
fb28ce6bbe
2 changed files with 11 additions and 10 deletions
|
@ -367,7 +367,7 @@ impl StrongRuleNode {
|
||||||
StrongRuleNode { p }
|
StrongRuleNode { p }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn downgrade(&self) -> WeakRuleNode {
|
fn downgrade(&self) -> WeakRuleNode {
|
||||||
unsafe { WeakRuleNode::from_ptr(self.p) }
|
unsafe { WeakRuleNode::from_ptr(self.p) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ impl StrongRuleNode {
|
||||||
|
|
||||||
pub(super) fn ensure_child(
|
pub(super) fn ensure_child(
|
||||||
&self,
|
&self,
|
||||||
root: WeakRuleNode,
|
root: &StrongRuleNode,
|
||||||
source: StyleSource,
|
source: StyleSource,
|
||||||
level: CascadeLevel,
|
level: CascadeLevel,
|
||||||
) -> StrongRuleNode {
|
) -> StrongRuleNode {
|
||||||
|
@ -404,6 +404,7 @@ impl StrongRuleNode {
|
||||||
key,
|
key,
|
||||||
|node| unsafe { (*node.ptr()).key() },
|
|node| unsafe { (*node.ptr()).key() },
|
||||||
move || {
|
move || {
|
||||||
|
let root = root.downgrade();
|
||||||
let strong =
|
let strong =
|
||||||
StrongRuleNode::new(Box::new(RuleNode::new(root, self.clone(), source, level)));
|
StrongRuleNode::new(Box::new(RuleNode::new(root, self.clone(), source, level)));
|
||||||
let weak = strong.downgrade();
|
let weak = strong.downgrade();
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl RuleTree {
|
||||||
debug_assert!(transition.is_none());
|
debug_assert!(transition.is_none());
|
||||||
transition = Some(source);
|
transition = Some(source);
|
||||||
} else {
|
} else {
|
||||||
current = current.ensure_child(self.root().downgrade(), source, level);
|
current = current.ensure_child(self.root(), source, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ impl RuleTree {
|
||||||
|
|
||||||
for (source, shadow_cascade_order) in important_author.drain(..) {
|
for (source, shadow_cascade_order) in important_author.drain(..) {
|
||||||
current = current.ensure_child(
|
current = current.ensure_child(
|
||||||
self.root().downgrade(),
|
self.root(),
|
||||||
source,
|
source,
|
||||||
AuthorImportant {
|
AuthorImportant {
|
||||||
shadow_cascade_order: -shadow_cascade_order,
|
shadow_cascade_order: -shadow_cascade_order,
|
||||||
|
@ -140,15 +140,15 @@ impl RuleTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
for source in important_user.drain(..) {
|
for source in important_user.drain(..) {
|
||||||
current = current.ensure_child(self.root().downgrade(), source, UserImportant);
|
current = current.ensure_child(self.root(), source, UserImportant);
|
||||||
}
|
}
|
||||||
|
|
||||||
for source in important_ua.drain(..) {
|
for source in important_ua.drain(..) {
|
||||||
current = current.ensure_child(self.root().downgrade(), source, UAImportant);
|
current = current.ensure_child(self.root(), source, UAImportant);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(source) = transition {
|
if let Some(source) = transition {
|
||||||
current = current.ensure_child(self.root().downgrade(), source, Transitions);
|
current = current.ensure_child(self.root(), source, Transitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
current
|
current
|
||||||
|
@ -182,7 +182,7 @@ impl RuleTree {
|
||||||
{
|
{
|
||||||
let mut current = from;
|
let mut current = from;
|
||||||
for (source, level) in iter {
|
for (source, level) in iter {
|
||||||
current = current.ensure_child(self.root().downgrade(), source, level);
|
current = current.ensure_child(self.root(), source, level);
|
||||||
}
|
}
|
||||||
current
|
current
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ impl RuleTree {
|
||||||
if level.is_important() {
|
if level.is_important() {
|
||||||
if pdb.read_with(level.guard(guards)).any_important() {
|
if pdb.read_with(level.guard(guards)).any_important() {
|
||||||
current = current.ensure_child(
|
current = current.ensure_child(
|
||||||
self.root().downgrade(),
|
self.root(),
|
||||||
StyleSource::from_declarations(pdb.clone_arc()),
|
StyleSource::from_declarations(pdb.clone_arc()),
|
||||||
level,
|
level,
|
||||||
);
|
);
|
||||||
|
@ -271,7 +271,7 @@ impl RuleTree {
|
||||||
} else {
|
} else {
|
||||||
if pdb.read_with(level.guard(guards)).any_normal() {
|
if pdb.read_with(level.guard(guards)).any_normal() {
|
||||||
current = current.ensure_child(
|
current = current.ensure_child(
|
||||||
self.root().downgrade(),
|
self.root(),
|
||||||
StyleSource::from_declarations(pdb.clone_arc()),
|
StyleSource::from_declarations(pdb.clone_arc()),
|
||||||
level,
|
level,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue