mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Massage the resolver code so it's cleaner and prevents the problem.
This way all the borrows stay in the sharing code, and prevents an extra borrow on a cache hit, which is not a big deal but nice.
This commit is contained in:
parent
36fed07b1c
commit
891bc7d174
6 changed files with 119 additions and 119 deletions
|
@ -284,13 +284,18 @@ impl ElementData {
|
|||
|
||||
/// Returns this element's primary style as a resolved style to use for sharing.
|
||||
pub fn share_primary_style(&self) -> PrimaryStyle {
|
||||
let primary_is_reused = self.flags.contains(PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
|
||||
PrimaryStyle(ResolvedStyle::new(self.styles.primary().clone(), primary_is_reused))
|
||||
let reused_via_rule_node =
|
||||
self.flags.contains(PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
|
||||
|
||||
PrimaryStyle {
|
||||
style: ResolvedStyle(self.styles.primary().clone()),
|
||||
reused_via_rule_node,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets a new set of styles, returning the old ones.
|
||||
pub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles {
|
||||
if new_styles.primary.0.reused_via_rule_node {
|
||||
if new_styles.primary.reused_via_rule_node {
|
||||
self.flags.insert(PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
|
||||
} else {
|
||||
self.flags.remove(PRIMARY_STYLE_REUSED_VIA_RULE_NODE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue