style: Remove StyleRelations. draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 11 Jul 2017 16:29:49 +0200
changeset 606882 122f8fc022e9944671f6afa7cc6ce63b7fd202f9
parent 606881 db1cac4f74bf73a675ad62b1961a47ada8dd59fb
child 636875 fa9ac857b1f3407df73ffa70d6ba74c1c78a9d1d
push id67817
push userbmo:emilio+bugs@crisal.io
push dateTue, 11 Jul 2017 14:32:38 +0000
milestone56.0a1
style: Remove StyleRelations. They're unused now. We can add them back if needed. MozReview-Commit-ID: 92Y2Na0ZbVn
servo/components/selectors/context.rs
servo/components/selectors/matching.rs
servo/components/style/stylist.rs
--- a/servo/components/selectors/context.rs
+++ b/servo/components/selectors/context.rs
@@ -1,28 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use attr::CaseSensitivity;
 use bloom::BloomFilter;
 
-bitflags! {
-    /// Set of flags that determine the different kind of elements affected by
-    /// the selector matching process.
-    ///
-    /// This is used to implement efficient sharing.
-    #[derive(Default)]
-    pub flags StyleRelations: usize {
-        /// Whether this element is affected by presentational hints. This is
-        /// computed externally (that is, in Servo).
-        const AFFECTED_BY_PRESENTATIONAL_HINTS = 1 << 0,
-    }
-}
-
 /// What kind of selector matching mode we should use.
 ///
 /// There are two modes of selector matching. The difference is only noticeable
 /// in presence of pseudo-elements.
 #[derive(Debug, PartialEq, Copy, Clone)]
 pub enum MatchingMode {
     /// Don't ignore any pseudo-element selectors.
     Normal,
@@ -82,19 +69,16 @@ impl QuirksMode {
     }
 }
 
 /// Data associated with the matching process for a element.  This context is
 /// used across many selectors for an element, so it's not appropriate for
 /// transient data that applies to only a single selector.
 #[derive(Clone)]
 pub struct MatchingContext<'a> {
-    /// Output that records certains relations between elements noticed during
-    /// matching (and also extended after matching).
-    pub relations: StyleRelations,
     /// Input with the matching mode we should use when matching selectors.
     pub matching_mode: MatchingMode,
     /// Input with the bloom filter used to fast-reject selectors.
     pub bloom_filter: Option<&'a BloomFilter>,
     /// Input that controls how matching for links is handled.
     pub visited_handling: VisitedHandlingMode,
     /// Output that records whether we encountered a "relevant link" while
     /// matching _any_ selector for this element. (This differs from
@@ -109,17 +93,16 @@ pub struct MatchingContext<'a> {
 impl<'a> MatchingContext<'a> {
     /// Constructs a new `MatchingContext`.
     pub fn new(matching_mode: MatchingMode,
                bloom_filter: Option<&'a BloomFilter>,
                quirks_mode: QuirksMode)
                -> Self
     {
         Self {
-            relations: StyleRelations::empty(),
             matching_mode: matching_mode,
             bloom_filter: bloom_filter,
             visited_handling: VisitedHandlingMode::AllLinksUnvisited,
             relevant_link_found: false,
             quirks_mode: quirks_mode,
             classes_and_ids_case_sensitivity: quirks_mode.classes_and_ids_case_sensitivity(),
         }
     }
@@ -127,17 +110,16 @@ impl<'a> MatchingContext<'a> {
     /// Constructs a new `MatchingContext` for use in visited matching.
     pub fn new_for_visited(matching_mode: MatchingMode,
                            bloom_filter: Option<&'a BloomFilter>,
                            visited_handling: VisitedHandlingMode,
                            quirks_mode: QuirksMode)
                            -> Self
     {
         Self {
-            relations: StyleRelations::empty(),
             matching_mode: matching_mode,
             bloom_filter: bloom_filter,
             visited_handling: visited_handling,
             relevant_link_found: false,
             quirks_mode: quirks_mode,
             classes_and_ids_case_sensitivity: quirks_mode.classes_and_ids_case_sensitivity(),
         }
     }
--- a/servo/components/selectors/matching.rs
+++ b/servo/components/selectors/matching.rs
@@ -709,18 +709,16 @@ fn matches_simple_selector<E, F>(
         Component::LastChild => {
             matches_last_child(element, flags_setter)
         }
         Component::OnlyChild => {
             matches_first_child(element, flags_setter) &&
             matches_last_child(element, flags_setter)
         }
         Component::Root => {
-            // We never share styles with an element with no parent, so no point
-            // in creating a new StyleRelation.
             element.is_root()
         }
         Component::Empty => {
             flags_setter(element, HAS_EMPTY_SELECTOR);
             element.is_empty()
         }
         Component::NthChild(a, b) => {
             matches_generic_nth_child(element, a, b, false, false, flags_setter)
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -21,17 +21,17 @@ use properties::{AnimationRules, Propert
 #[cfg(feature = "servo")]
 use properties::INHERIT_ALL;
 use rule_tree::{CascadeLevel, RuleTree, StyleSource};
 use selector_map::{SelectorMap, SelectorMapEntry};
 use selector_parser::{SelectorImpl, PseudoElement};
 use selectors::attr::NamespaceConstraint;
 use selectors::bloom::BloomFilter;
 use selectors::matching::{ElementSelectorFlags, matches_selector, MatchingContext, MatchingMode};
-use selectors::matching::{VisitedHandlingMode, AFFECTED_BY_PRESENTATIONAL_HINTS};
+use selectors::matching::VisitedHandlingMode;
 use selectors::parser::{AncestorHashes, Combinator, Component, Selector, SelectorAndHashes};
 use selectors::parser::{SelectorIter, SelectorMethods};
 use selectors::sink::Push;
 use selectors::visitor::SelectorVisitor;
 use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
 use smallvec::VecLike;
 use std::fmt::Debug;
 #[cfg(feature = "servo")]
@@ -1140,37 +1140,31 @@ impl Stylist {
         // Step 1: Normal user-agent rules.
         map.user_agent.get_all_matching_rules(element,
                                               &rule_hash_target,
                                               applicable_declarations,
                                               context,
                                               self.quirks_mode,
                                               flags_setter,
                                               CascadeLevel::UANormal);
-        debug!("UA normal: {:?}", context.relations);
 
         if pseudo_element.is_none() && !only_default_rules {
             // Step 2: Presentational hints.
             let length_before_preshints = applicable_declarations.len();
             element.synthesize_presentational_hints_for_legacy_attributes(
                 context.visited_handling,
                 applicable_declarations
             );
             if applicable_declarations.len() != length_before_preshints {
                 if cfg!(debug_assertions) {
                     for declaration in &applicable_declarations[length_before_preshints..] {
                         assert_eq!(declaration.level(), CascadeLevel::PresHints);
                     }
                 }
-                // Note the existence of presentational attributes so that the
-                // style sharing cache can avoid re-querying them if they don't
-                // exist.
-                context.relations |= AFFECTED_BY_PRESENTATIONAL_HINTS;
             }
-            debug!("preshints: {:?}", context.relations);
         }
 
         // NB: the following condition, although it may look somewhat
         // inaccurate, would be equivalent to something like:
         //
         //     element.matches_user_and_author_rules() ||
         //     (is_implemented_pseudo &&
         //      rule_hash_target.matches_user_and_author_rules())
@@ -1180,77 +1174,71 @@ impl Stylist {
             // Step 3a: User normal rules.
             map.user.get_all_matching_rules(element,
                                             &rule_hash_target,
                                             applicable_declarations,
                                             context,
                                             self.quirks_mode,
                                             flags_setter,
                                             CascadeLevel::UserNormal);
-            debug!("user normal: {:?}", context.relations);
         } else {
             debug!("skipping user rules");
         }
 
         // Step 3b: XBL rules.
         let cut_off_inheritance =
             element.get_declarations_from_xbl_bindings(pseudo_element,
                                                        applicable_declarations);
-        debug!("XBL: {:?}", context.relations);
 
         if rule_hash_target.matches_user_and_author_rules() && !only_default_rules {
             // Gecko skips author normal rules if cutting off inheritance.
             // See nsStyleSet::FileRules().
             if !cut_off_inheritance {
                 // Step 3c: Author normal rules.
                 map.author.get_all_matching_rules(element,
                                                   &rule_hash_target,
                                                   applicable_declarations,
                                                   context,
                                               self.quirks_mode,
                                                   flags_setter,
                                                   CascadeLevel::AuthorNormal);
-                debug!("author normal: {:?}", context.relations);
             } else {
                 debug!("skipping author normal rules due to cut off inheritance");
             }
         } else {
             debug!("skipping author normal rules");
         }
 
         if !only_default_rules {
             // Step 4: Normal style attributes.
             if let Some(sa) = style_attribute {
                 Push::push(
                     applicable_declarations,
                     ApplicableDeclarationBlock::from_declarations(sa.clone(),
                                                                   CascadeLevel::StyleAttributeNormal));
             }
-            debug!("style attr: {:?}", context.relations);
 
             // Step 5: SMIL override.
             // Declarations from SVG SMIL animation elements.
             if let Some(so) = smil_override {
                 Push::push(
                     applicable_declarations,
                     ApplicableDeclarationBlock::from_declarations(so.clone(),
                                                                   CascadeLevel::SMILOverride));
             }
-            debug!("SMIL: {:?}", context.relations);
 
             // Step 6: Animations.
             // The animations sheet (CSS animations, script-generated animations,
             // and CSS transitions that are no longer tied to CSS markup)
             if let Some(anim) = animation_rules.0 {
                 Push::push(
                     applicable_declarations,
                     ApplicableDeclarationBlock::from_declarations(anim.clone(),
                                                                   CascadeLevel::Animations));
             }
-            debug!("animation: {:?}", context.relations);
         } else {
             debug!("skipping style attr and SMIL & animation rules");
         }
 
         //
         // Steps 7-10 correspond to !important rules, and are handled during
         // rule tree insertion.
         //
@@ -1259,22 +1247,19 @@ impl Stylist {
             // Step 11: Transitions.
             // The transitions sheet (CSS transitions that are tied to CSS markup)
             if let Some(anim) = animation_rules.1 {
                 Push::push(
                     applicable_declarations,
                     ApplicableDeclarationBlock::from_declarations(anim.clone(),
                                                                   CascadeLevel::Transitions));
             }
-            debug!("transition: {:?}", context.relations);
         } else {
             debug!("skipping transition rules");
         }
-
-        debug!("push_applicable_declarations: shareable: {:?}", context.relations);
     }
 
     /// Given an id, returns whether there might be any rules for that id in any
     /// of our rule maps.
     #[inline]
     pub fn may_have_rules_for_id(&self, id: &Atom) -> bool {
         self.mapped_ids.might_contain_hash(id.get_hash())
     }