diff --git a/components/style/dom.rs b/components/style/dom.rs index 0a5733303db..81c1e89da0f 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -31,7 +31,7 @@ use std::fmt; use std::fmt::Debug; use std::hash::Hash; use std::ops::Deref; -use stylist::{CascadeData, Stylist}; +use stylist::CascadeData; use traversal_flags::TraversalFlags; /// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed @@ -751,10 +751,10 @@ pub trait TElement /// Implements Gecko's `nsBindingManager::WalkRules`. /// /// Returns whether to cut off the inheritance. - fn each_xbl_stylist<'a, F>(&self, _: F) -> bool + fn each_xbl_cascade_data<'a, F>(&self, _: F) -> bool where Self: 'a, - F: FnMut(AtomicRef<'a, Stylist>), + F: FnMut(AtomicRef<'a, CascadeData>, QuirksMode), { false } @@ -768,24 +768,11 @@ pub trait TElement Self: 'a, F: FnMut(AtomicRef<'a, CascadeData>, QuirksMode), { - let cut_off_inheritance = self.each_xbl_stylist(|stylist| { - let quirks_mode = stylist.quirks_mode(); - f( - AtomicRef::map(stylist, |stylist| stylist.author_cascade_data()), - quirks_mode, - ) - }); + let cut_off_inheritance = self.each_xbl_cascade_data(&mut f); let mut current = self.assigned_slot(); while let Some(slot) = current { - slot.each_xbl_stylist(|stylist| { - let quirks_mode = stylist.quirks_mode(); - f( - AtomicRef::map(stylist, |stylist| stylist.author_cascade_data()), - quirks_mode, - ) - }); - + slot.each_xbl_cascade_data(&mut f); current = slot.assigned_slot(); } @@ -794,8 +781,9 @@ pub trait TElement /// Gets the current existing CSS transitions, by |property, end value| pairs in a FnvHashMap. #[cfg(feature = "gecko")] - fn get_css_transitions_info(&self) - -> FnvHashMap>; + fn get_css_transitions_info( + &self, + ) -> FnvHashMap>; /// Does a rough (and cheap) check for whether or not transitions might need to be updated that /// will quickly return false for the common case of no transitions specified or running. If diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index fdca4af3dd2..b4d4b42ee0a 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -86,7 +86,7 @@ use std::mem; use std::ops::DerefMut; use std::ptr; use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; -use stylist::Stylist; +use stylist::CascadeData; /// A simple wrapper over `nsIDocument`. #[derive(Clone, Copy)] @@ -429,12 +429,12 @@ impl<'lb> GeckoXBLBinding<'lb> { } } - fn each_xbl_stylist(&self, f: &mut F) + fn each_xbl_cascade_data(&self, f: &mut F) where - F: FnMut(AtomicRef<'lb, Stylist>), + F: FnMut(AtomicRef<'lb, CascadeData>, QuirksMode), { if let Some(base) = self.base_binding() { - base.each_xbl_stylist(f); + base.each_xbl_cascade_data(f); } let raw_data = unsafe { @@ -443,7 +443,8 @@ impl<'lb> GeckoXBLBinding<'lb> { if let Some(raw_data) = raw_data { let data = PerDocumentStyleData::from_ffi(&*raw_data).borrow(); - f(AtomicRef::map(data, |d| &d.stylist)); + let quirks_mode = data.stylist.quirks_mode(); + f(AtomicRef::map(data, |d| d.stylist.author_cascade_data()), quirks_mode); } } } @@ -1374,10 +1375,10 @@ impl<'le> TElement for GeckoElement<'le> { self.may_have_animations() && unsafe { Gecko_ElementHasCSSTransitions(self.0) } } - fn each_xbl_stylist<'a, F>(&self, mut f: F) -> bool + fn each_xbl_cascade_data<'a, F>(&self, mut f: F) -> bool where 'le: 'a, - F: FnMut(AtomicRef<'a, Stylist>), + F: FnMut(AtomicRef<'a, CascadeData>, QuirksMode), { // Walk the binding scope chain, starting with the binding attached to // our content, up till we run out of scopes or we get cut off. @@ -1388,7 +1389,7 @@ impl<'le> TElement for GeckoElement<'le> { while let Some(element) = current { if let Some(binding) = element.get_xbl_binding() { - binding.each_xbl_stylist(&mut f); + binding.each_xbl_cascade_data(&mut f); // If we're not looking at our original element, allow the // binding to cut off style inheritance. @@ -1416,8 +1417,7 @@ impl<'le> TElement for GeckoElement<'le> { fn xbl_binding_anonymous_content(&self) -> Option> { self.get_xbl_binding_with_content() - .map(|b| unsafe { b.anon_content().as_ref() }.unwrap()) - .map(GeckoNode::from_content) + .map(|b| unsafe { GeckoNode::from_content(&*b.anon_content()) }) } fn get_css_transitions_info( diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 56f7f4b2fea..8c55761733c 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -1268,8 +1268,8 @@ impl Stylist { } for slot in slots.iter().rev() { - slot.each_xbl_stylist(|stylist| { - if let Some(map) = stylist.cascade_data.author.slotted_rules(pseudo_element) { + slot.each_xbl_cascade_data(|cascade_data, _quirks_mode| { + if let Some(map) = cascade_data.slotted_rules(pseudo_element) { map.get_all_matching_rules( element, rule_hash_target, @@ -1287,8 +1287,8 @@ impl Stylist { // even for getDefaultComputedStyle! // // Also, this doesn't account for the author_styles_enabled stuff. - let cut_off_inheritance = element.each_xbl_stylist(|stylist| { - if let Some(map) = stylist.cascade_data.author.normal_rules(pseudo_element) { + let cut_off_inheritance = element.each_xbl_cascade_data(|cascade_data, quirks_mode| { + if let Some(map) = cascade_data.normal_rules(pseudo_element) { // NOTE(emilio): This is needed because the XBL stylist may // think it has a different quirks mode than the document. // @@ -1299,7 +1299,7 @@ impl Stylist { context.matching_mode(), context.bloom_filter, context.nth_index_cache.as_mut().map(|s| &mut **s), - stylist.quirks_mode, + quirks_mode, ); matching_context.pseudo_element_matching_fn = context.pseudo_element_matching_fn;