diff options
Diffstat (limited to 'components/style/rule_tree/mod.rs')
-rw-r--r-- | components/style/rule_tree/mod.rs | 258 |
1 files changed, 0 insertions, 258 deletions
diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 113fa9cb9bb..484cdee5183 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -7,8 +7,6 @@ //! The rule tree. use crate::applicable_declarations::ApplicableDeclarationList; -#[cfg(feature = "gecko")] -use crate::gecko::selector_parser::PseudoElement; use crate::hash::{self, FxHashMap}; use crate::properties::{Importance, LonghandIdSet, PropertyDeclarationBlock}; use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; @@ -136,29 +134,6 @@ impl StyleSource { let _ = write!(writer, " -> {:?}", self.read(guard).declarations()); } - // This is totally unsafe, should be removed when we figure out the cause of - // bug 1607553. - #[cfg(feature = "gecko")] - unsafe fn dump_unchecked<W: Write>(&self, writer: &mut W) { - if let Some(ref rule) = self.0.as_first() { - let rule = rule.read_unchecked(); - let _ = write!(writer, "{:?}", rule.selectors); - } - let _ = write!(writer, " -> {:?}", self.read_unchecked().declarations()); - } - - // This is totally unsafe, should be removed when we figure out the cause of - // bug 1607553. - #[inline] - #[cfg(feature = "gecko")] - unsafe fn read_unchecked(&self) -> &PropertyDeclarationBlock { - let block: &Locked<PropertyDeclarationBlock> = match self.0.borrow() { - ArcUnionBorrow::First(ref rule) => &rule.get().read_unchecked().block, - ArcUnionBorrow::Second(ref block) => block.get(), - }; - block.read_unchecked() - } - /// Read the style source guard, and obtain thus read access to the /// underlying property declaration block. #[inline] @@ -1441,198 +1416,6 @@ impl StrongRuleNode { } } - /// Returns true if any properties specified by `rule_type_mask` was set by - /// an author rule. - #[cfg(feature = "gecko")] - pub fn has_author_specified_rules<E>( - &self, - mut element: E, - mut pseudo: Option<PseudoElement>, - guards: &StylesheetGuards, - rule_type_mask: u32, - author_colors_allowed: bool, - ) -> bool - where - E: crate::dom::TElement, - { - use crate::gecko_bindings::structs::NS_AUTHOR_SPECIFIED_BACKGROUND; - use crate::gecko_bindings::structs::NS_AUTHOR_SPECIFIED_BORDER; - use crate::gecko_bindings::structs::NS_AUTHOR_SPECIFIED_PADDING; - use crate::properties::{CSSWideKeyword, LonghandId}; - use crate::properties::{PropertyDeclaration, PropertyDeclarationId}; - use std::borrow::Cow; - - // Reset properties: - const BACKGROUND_PROPS: &'static [LonghandId] = - &[LonghandId::BackgroundColor, LonghandId::BackgroundImage]; - - const BORDER_PROPS: &'static [LonghandId] = &[ - LonghandId::BorderTopColor, - LonghandId::BorderTopStyle, - LonghandId::BorderTopWidth, - LonghandId::BorderRightColor, - LonghandId::BorderRightStyle, - LonghandId::BorderRightWidth, - LonghandId::BorderBottomColor, - LonghandId::BorderBottomStyle, - LonghandId::BorderBottomWidth, - LonghandId::BorderLeftColor, - LonghandId::BorderLeftStyle, - LonghandId::BorderLeftWidth, - LonghandId::BorderTopLeftRadius, - LonghandId::BorderTopRightRadius, - LonghandId::BorderBottomRightRadius, - LonghandId::BorderBottomLeftRadius, - LonghandId::BorderInlineStartColor, - LonghandId::BorderInlineStartStyle, - LonghandId::BorderInlineStartWidth, - LonghandId::BorderInlineEndColor, - LonghandId::BorderInlineEndStyle, - LonghandId::BorderInlineEndWidth, - LonghandId::BorderBlockStartColor, - LonghandId::BorderBlockStartStyle, - LonghandId::BorderBlockStartWidth, - LonghandId::BorderBlockEndColor, - LonghandId::BorderBlockEndStyle, - LonghandId::BorderBlockEndWidth, - ]; - - const PADDING_PROPS: &'static [LonghandId] = &[ - LonghandId::PaddingTop, - LonghandId::PaddingRight, - LonghandId::PaddingBottom, - LonghandId::PaddingLeft, - LonghandId::PaddingInlineStart, - LonghandId::PaddingInlineEnd, - LonghandId::PaddingBlockStart, - LonghandId::PaddingBlockEnd, - ]; - - // Set of properties that we are currently interested in. - let mut properties = LonghandIdSet::new(); - - if rule_type_mask & NS_AUTHOR_SPECIFIED_BACKGROUND != 0 { - for id in BACKGROUND_PROPS { - properties.insert(*id); - } - } - if rule_type_mask & NS_AUTHOR_SPECIFIED_BORDER != 0 { - for id in BORDER_PROPS { - properties.insert(*id); - } - } - if rule_type_mask & NS_AUTHOR_SPECIFIED_PADDING != 0 { - for id in PADDING_PROPS { - properties.insert(*id); - } - } - - // If author colors are not allowed, don't look at those properties - // (except for background-color which is special and we handle below). - if !author_colors_allowed { - properties.remove_all(LonghandIdSet::ignored_when_colors_disabled()); - if rule_type_mask & NS_AUTHOR_SPECIFIED_BACKGROUND != 0 { - properties.insert(LonghandId::BackgroundColor); - } - } - - let mut element_rule_node = Cow::Borrowed(self); - - loop { - // We need to be careful not to count styles covered up by - // user-important or UA-important declarations. But we do want to - // catch explicit inherit styling in those and check our parent - // element to see whether we have user styling for those properties. - // Note that we don't care here about inheritance due to lack of a - // specified value, since all the properties we care about are reset - // properties. - - let mut inherited_properties = LonghandIdSet::new(); - let mut have_explicit_ua_inherit = false; - - for node in element_rule_node.self_and_ancestors() { - let source = node.style_source(); - let declarations = if source.is_some() { - source - .as_ref() - .unwrap() - .read(node.cascade_level().guard(guards)) - .declaration_importance_iter() - } else { - continue; - }; - - // Iterate over declarations of the longhands we care about. - let node_importance = node.importance(); - let longhands = declarations.rev().filter_map(|(declaration, importance)| { - if importance != node_importance { - return None; - } - match declaration.id() { - PropertyDeclarationId::Longhand(id) => Some((id, declaration)), - _ => None, - } - }); - - let is_author = node.cascade_level().origin() == Origin::Author; - for (id, declaration) in longhands { - if !properties.contains(id) { - continue; - } - - if is_author { - if !author_colors_allowed { - if let PropertyDeclaration::BackgroundColor(ref color) = *declaration { - if color.is_transparent() { - return true; - } - continue; - } - } - return true; - } - - // This property was set by a non-author rule. - // Stop looking for it in this element's rule - // nodes. - properties.remove(id); - - // However, if it is inherited, then it might be - // inherited from an author rule from an - // ancestor element's rule nodes. - if declaration.get_css_wide_keyword() == Some(CSSWideKeyword::Inherit) { - have_explicit_ua_inherit = true; - inherited_properties.insert(id); - } - } - } - - if !have_explicit_ua_inherit { - break; - } - - // Continue to the parent element and search for the inherited properties. - if let Some(pseudo) = pseudo.take() { - if pseudo.inherits_from_default_values() { - break; - } - } else { - element = match element.inheritance_parent() { - Some(parent) => parent, - None => break, - }; - - let parent_data = element.mutate_data().unwrap(); - let parent_rule_node = parent_data.styles.primary().rules().clone(); - element_rule_node = Cow::Owned(parent_rule_node); - } - - properties = inherited_properties; - } - - false - } - /// Returns true if there is either animation or transition level rule. pub fn has_animation_or_transition_rules(&self) -> bool { self.self_and_ancestors() @@ -1742,47 +1525,6 @@ impl Drop for StrongRuleNode { return; } - #[cfg(feature = "gecko")] - #[inline(always)] - fn assert_on_release() -> bool { - crate::gecko_bindings::structs::GECKO_IS_NIGHTLY - } - - #[cfg(feature = "servo")] - fn assert_on_release() -> bool { - false - } - - if cfg!(debug_assertions) || assert_on_release() { - let children = node.children.read(); - if !children.is_empty() { - let mut crash_str = vec![]; - - #[cfg(feature = "gecko")] - unsafe { - // Try to unsafely collect some information of this before - // crashing the process. - if let Some(ref s) = node.source { - s.dump_unchecked(&mut crash_str); - crash_str.push(b'\n'); - } - children.each(|child| { - (*child.ptr()) - .source - .as_ref() - .unwrap() - .dump_unchecked(&mut crash_str); - crash_str.push(b'\n'); - }); - } - - panic!( - "Children left in the rule tree on drop: {}", - String::from_utf8_lossy(&crash_str).trim() - ); - } - } - if node.parent.is_none() { debug!("Dropping root node!"); // The free list should be null by this point |