Stop using Ref::map for style().

It's not possible to implement a Ref::map equivalent method on AtomicRefCell
while having AtomicRefCell implemented on top of RwArc. We could potentially
reimplement AtomicRefCell to be more like RefCell and add a Ref::map equivalent
method, but I (and pcwalton) think we should try just cloning a few extra
Arcs at these callsites instead.

MozReview-Commit-ID: 6H8vAWguO3z
This commit is contained in:
Bobby Holley 2016-09-29 17:43:04 -07:00
parent 518324cff6
commit 18d552a1e9
5 changed files with 20 additions and 28 deletions

View file

@ -240,12 +240,11 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + NodeInfo + PartialEq + Sized {
///
/// Unlike the version on TNode, this handles pseudo-elements.
#[inline]
fn style(&self, context: &SharedStyleContext) -> Ref<Arc<ServoComputedValues>> {
fn style(&self, context: &SharedStyleContext) -> Arc<ServoComputedValues> {
match self.get_pseudo_element_type() {
PseudoElementType::Normal => {
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
data.style_data.style.as_ref().unwrap()
})
self.get_style_data().unwrap().borrow()
.style_data.style.as_ref().unwrap().clone()
},
other => {
// Precompute non-eagerly-cascaded pseudo-element styles if not
@ -289,9 +288,9 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + NodeInfo + PartialEq + Sized {
}
}
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
data.style_data.per_pseudo.get(&style_pseudo).unwrap()
})
self.get_style_data().unwrap().borrow()
.style_data.per_pseudo.get(&style_pseudo)
.unwrap().clone()
}
}
}