From 2dd2c9cedde733f30042163c20e763b243567780 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 4 Nov 2016 16:54:21 +0100 Subject: [PATCH] Simplify rule_tree::StyleSourceGuardHandle --- components/style/rule_tree/mod.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 93f33dc0d1e..1b32ab287e8 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -8,7 +8,6 @@ use arc_ptr_eq; #[cfg(feature = "servo")] use heapsize::HeapSizeOf; use owning_handle::OwningHandle; -use owning_ref::{ArcRef, OwningRef}; use parking_lot::{RwLock, RwLockReadGuard}; use properties::{Importance, PropertyDeclarationBlock}; use std::io::{self, Write}; @@ -30,12 +29,9 @@ pub enum StyleSource { Declarations(Arc>), } -// This is really nasty. type StyleSourceGuardHandle<'a> = OwningHandle< - OwningHandle< - OwningRef>, RwLock>, - RwLockReadGuard<'a, StyleRule>>, + RwLockReadGuard<'a, StyleRule>, RwLockReadGuard<'a, PropertyDeclarationBlock>>; pub enum StyleSourceGuard<'a> { @@ -80,13 +76,8 @@ impl StyleSource { use self::StyleSource::*; match *self { Style(ref rule) => { - let arc_ref = ArcRef::new(rule.clone()); - let rule_owning_ref = - OwningHandle::new(arc_ref, |r| unsafe { &*r }.read()); - let block_owning_ref = - OwningHandle::new(rule_owning_ref, |r| unsafe { &*r }.block.read()); - - StyleSourceGuard::Style(block_owning_ref) + let owning_ref = OwningHandle::new(rule.read(), |r| unsafe { &*r }.block.read()); + StyleSourceGuard::Style(owning_ref) } Declarations(ref block) => StyleSourceGuard::Declarations(block.read()), } @@ -325,7 +316,7 @@ impl StrongRuleNode { last = Some(child); } - let node = Box::new(RuleNode::new(root.clone(), + let node = Box::new(RuleNode::new(root, self.clone(), source.clone(), importance));