diff options
-rw-r--r-- | components/layout/incremental.rs | 13 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 44 | ||||
-rw-r--r-- | components/style/animation.rs | 2 | ||||
-rw-r--r-- | components/style/data.rs | 2 | ||||
-rw-r--r-- | components/style/dom.rs | 2 | ||||
-rw-r--r-- | components/style/matching.rs | 39 | ||||
-rw-r--r-- | ports/geckolib/wrapper.rs | 2 |
7 files changed, 52 insertions, 52 deletions
diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index 6865d037651..9bf4aff2e14 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -49,7 +49,7 @@ bitflags! { } impl TRestyleDamage for RestyleDamage { - fn compute(old: &Option<Arc<ComputedValues>>, new: &ComputedValues) -> RestyleDamage { compute_damage(old, new) } + fn compute(old: Option<&Arc<ComputedValues>>, new: &ComputedValues) -> RestyleDamage { compute_damage(old, new) } /// Returns a bitmask that represents a flow that needs to be rebuilt and reflowed. /// @@ -143,12 +143,11 @@ macro_rules! add_if_not_equal( }) ); -pub fn compute_damage(old: &Option<Arc<ComputedValues>>, new: &ComputedValues) -> RestyleDamage { - let old: &ComputedValues = - match old.as_ref() { - None => return RestyleDamage::rebuild_and_reflow(), - Some(cv) => &**cv, - }; +pub fn compute_damage(old: Option<&Arc<ComputedValues>>, new: &ComputedValues) -> RestyleDamage { + let old: &ComputedValues = match old { + None => return RestyleDamage::rebuild_and_reflow(), + Some(cv) => &**cv, + }; let mut damage = RestyleDamage::empty(); diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index faacdbf44f0..3174bed38a4 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -666,7 +666,8 @@ pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized { fn get_before_pseudo(&self) -> Option<Self> { self.borrow_layout_data().unwrap() .style_data.per_pseudo - .get(&PseudoElement::Before).unwrap_or(&None).as_ref().map(|style| { + .get(&PseudoElement::Before) + .map(|style| { self.with_pseudo(PseudoElementType::Before(style.get_box().display)) }) } @@ -675,7 +676,8 @@ pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized { fn get_after_pseudo(&self) -> Option<Self> { self.borrow_layout_data().unwrap() .style_data.per_pseudo - .get(&PseudoElement::After).unwrap_or(&None).as_ref().map(|style| { + .get(&PseudoElement::After) + .map(|style| { self.with_pseudo(PseudoElementType::After(style.get_box().display)) }) } @@ -700,11 +702,11 @@ pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized { fn style(&self) -> Ref<Arc<ComputedValues>> { Ref::map(self.borrow_layout_data().unwrap(), |data| { let style = match self.get_pseudo_element_type() { - PseudoElementType::Before(_) => data.style_data.per_pseudo.get(&PseudoElement::Before).unwrap(), - PseudoElementType::After(_) => data.style_data.per_pseudo.get(&PseudoElement::After).unwrap(), - PseudoElementType::Normal => &data.style_data.style, + PseudoElementType::Before(_) => data.style_data.per_pseudo.get(&PseudoElement::Before), + PseudoElementType::After(_) => data.style_data.per_pseudo.get(&PseudoElement::After), + PseudoElementType::Normal => data.style_data.style.as_ref(), }; - style.as_ref().unwrap() + style.unwrap() }) } @@ -713,24 +715,18 @@ pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized { /// Unlike the version on TNode, this handles pseudo-elements. fn unstyle(self) { let mut data = self.mutate_layout_data().unwrap(); - let style = - match self.get_pseudo_element_type() { - PseudoElementType::Before(_) => { - match data.style_data.per_pseudo.get_mut(&PseudoElement::Before) { - None => return, - Some(style) => style, - } - } - PseudoElementType::After(_) => { - match data.style_data.per_pseudo.get_mut(&PseudoElement::After) { - None => return, - Some(style) => style, - } - } - PseudoElementType::Normal => &mut data.style_data.style, - }; - *style = None; + match self.get_pseudo_element_type() { + PseudoElementType::Before(_) => { + data.style_data.per_pseudo.remove(&PseudoElement::Before); + } + PseudoElementType::After(_) => { + data.style_data.per_pseudo.remove(&PseudoElement::After); + } + PseudoElementType::Normal => { + data.style_data.style = None; + } + }; } fn is_ignorable_whitespace(&self) -> bool; @@ -953,7 +949,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> { data.per_pseudo.get(&PseudoElement::After).unwrap() }; - return match style.as_ref().unwrap().get_box().content { + return match style.as_ref().get_box().content { content::T::Content(ref value) if !value.is_empty() => { TextContent::GeneratedContent((*value).clone()) } diff --git a/components/style/animation.rs b/components/style/animation.rs index 10f96b19b1c..2dece839686 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -979,7 +979,7 @@ pub fn update_style_for_animation<ConcreteRestyleDamage: TRestyleDamage>(animati let mut new_style = (*style).clone(); animation.property_animation.update(&mut *Arc::make_mut(&mut new_style), progress); if let Some(damage) = damage { - *damage = *damage | ConcreteRestyleDamage::compute(&Some((*style).clone()), &new_style); + *damage = *damage | ConcreteRestyleDamage::compute(Some(style), &new_style); } *style = new_style diff --git a/components/style/data.rs b/components/style/data.rs index e2e806cee26..ffe12908cba 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -14,7 +14,7 @@ pub struct PrivateStyleData<Impl: SelectorImpl> { pub style: Option<Arc<ComputedValues>>, /// The results of CSS styling for each pseudo-element (if any). - pub per_pseudo: HashMap<Impl::PseudoElement, Option<Arc<ComputedValues>>, BuildHasherDefault<::fnv::FnvHasher>>, + pub per_pseudo: HashMap<Impl::PseudoElement, Arc<ComputedValues>, BuildHasherDefault<::fnv::FnvHasher>>, /// Information needed during parallel traversals. pub parallel: DomParallelInfo, diff --git a/components/style/dom.rs b/components/style/dom.rs index f4df206d32f..dfffe1eb131 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -44,7 +44,7 @@ impl OpaqueNode { } pub trait TRestyleDamage : BitOr<Output=Self> + Copy { - fn compute(old: &Option<Arc<ComputedValues>>, new: &ComputedValues) -> Self; + fn compute(old: Option<&Arc<ComputedValues>>, new: &ComputedValues) -> Self; fn rebuild_and_reflow() -> Self; } diff --git a/components/style/matching.rs b/components/style/matching.rs index b33d9fcd6da..74ae2971940 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -370,16 +370,16 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> context: &SharedStyleContext<<Self::ConcreteElement as Element>::Impl>, parent_style: Option<&Arc<ComputedValues>>, applicable_declarations: &[DeclarationBlock], - style: &mut Option<Arc<ComputedValues>>, + mut style: Option<&mut Arc<ComputedValues>>, applicable_declarations_cache: &mut ApplicableDeclarationsCache, new_animations_sender: &Mutex<Sender<Animation>>, shareable: bool, animate_properties: bool) - -> Self::ConcreteRestyleDamage { + -> (Self::ConcreteRestyleDamage, Arc<ComputedValues>) { let mut cacheable = true; if animate_properties { - cacheable = !self.update_animations_for_cascade(context, style) && cacheable; + cacheable = !self.update_animations_for_cascade(context, &mut style) && cacheable; } let mut this_style; @@ -414,7 +414,7 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> // Trigger transitions if necessary. This will reset `this_style` back to its old value if // it did trigger a transition. if animate_properties { - if let Some(ref style) = *style { + if let Some(ref style) = style { let animations_started = animation::start_transitions_if_applicable(new_animations_sender, self.opaque(), @@ -426,7 +426,7 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> // Calculate style difference. let this_style = Arc::new(this_style); - let damage = Self::ConcreteRestyleDamage::compute(style, &*this_style); + let damage = Self::ConcreteRestyleDamage::compute(style.map(|s| &*s), &*this_style); // Cache the resolved style if it was cacheable. if cacheable { @@ -434,14 +434,13 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> this_style.clone()); } - // Write in the final style and return the damage done to our caller. - *style = Some(this_style); - damage + // Return the final style and the damage done to our caller. + (damage, this_style) } fn update_animations_for_cascade(&self, context: &SharedStyleContext<<Self::ConcreteElement as Element>::Impl>, - style: &mut Option<Arc<ComputedValues>>) + style: &mut Option<&mut Arc<ComputedValues>>) -> bool { let style = match *style { None => return false, @@ -572,7 +571,7 @@ pub trait ElementMatchMethods<'le> : TElement<'le> let node = self.as_node(); let style = &mut node.mutate_data().unwrap().style; let damage = <<Self as TElement<'le>>::ConcreteNode as TNode<'le>> - ::ConcreteRestyleDamage::compute(style, &*shared_style); + ::ConcreteRestyleDamage::compute((*style).as_ref(), &*shared_style); *style = Some(shared_style); return StyleSharingResult::StyleWasShared(i, damage) } @@ -666,38 +665,44 @@ pub trait MatchMethods<'ln> : TNode<'ln> { let cloned_parent_style = parent_style.unwrap().clone(); data.style = Some(cloned_parent_style); } else { - let mut damage; - { + let damage = { let mut data_ref = self.mutate_data().unwrap(); let mut data = &mut *data_ref; - damage = self.cascade_node_pseudo_element( + let (mut damage, final_style) = self.cascade_node_pseudo_element( context, parent_style, &applicable_declarations.normal, - &mut data.style, + data.style.as_mut(), applicable_declarations_cache, new_animations_sender, applicable_declarations.normal_shareable, true); + data.style = Some(final_style); + <Self::ConcreteElement as Element>::Impl::each_eagerly_cascaded_pseudo_element(|pseudo| { let applicable_declarations_for_this_pseudo = applicable_declarations.per_pseudo.get(&pseudo).unwrap(); if !applicable_declarations_for_this_pseudo.is_empty() { - damage = damage | self.cascade_node_pseudo_element( + let (new_damage, style) = self.cascade_node_pseudo_element( context, Some(data.style.as_ref().unwrap()), &*applicable_declarations_for_this_pseudo, - data.per_pseudo.entry(pseudo).or_insert(None), + data.per_pseudo.get_mut(&pseudo), applicable_declarations_cache, new_animations_sender, false, false); + data.per_pseudo.insert(pseudo, style); + + damage = damage | new_damage; } }); - } + + damage + }; // This method needs to borrow the data as mutable, so make sure data_ref goes out of // scope first. diff --git a/ports/geckolib/wrapper.rs b/ports/geckolib/wrapper.rs index c650d9c6dee..00f54f175b6 100644 --- a/ports/geckolib/wrapper.rs +++ b/ports/geckolib/wrapper.rs @@ -78,7 +78,7 @@ impl<'ln> GeckoNode<'ln> { #[derive(Clone, Copy)] pub struct DummyRestyleDamage; impl TRestyleDamage for DummyRestyleDamage { - fn compute(_: &Option<Arc<ComputedValues>>, _: &ComputedValues) -> Self { DummyRestyleDamage } + fn compute(_: Option<&Arc<ComputedValues>>, _: &ComputedValues) -> Self { DummyRestyleDamage } fn rebuild_and_reflow() -> Self { DummyRestyleDamage } } impl BitOr for DummyRestyleDamage { |