Bug 1422538: Rename ServoElementSnapshotFlags::MaybeClass to just Class. r?bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 02 Dec 2017 23:22:31 +0100
changeset 706634 55a4d79187e839bcc2a1b0b018866ff955b400cf
parent 706633 08ae8ed544f1c633dc86f5030bc450f5d527bb42
child 706635 679bc0250123c5e696c94109666b035a33b10a1b
push id91862
push userbmo:emilio@crisal.io
push dateSat, 02 Dec 2017 23:34:31 +0000
reviewersbz
bugs1422538
milestone59.0a1
Bug 1422538: Rename ServoElementSnapshotFlags::MaybeClass to just Class. r?bz Since it's exact... MozReview-Commit-ID: Fx3VWe4cjCN
layout/style/ServoElementSnapshot.h
servo/components/style/gecko/snapshot.rs
--- a/layout/style/ServoElementSnapshot.h
+++ b/layout/style/ServoElementSnapshot.h
@@ -45,17 +45,17 @@ struct ServoAttrSnapshot
  * A bitflags enum class used to determine what data does a ServoElementSnapshot
  * contains.
  */
 enum class ServoElementSnapshotFlags : uint8_t
 {
   State = 1 << 0,
   Attributes = 1 << 1,
   Id = 1 << 2,
-  MaybeClass = 1 << 3,
+  Class = 1 << 3,
   OtherPseudoClassState = 1 << 4,
 };
 
 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ServoElementSnapshotFlags)
 
 /**
  * This class holds all non-tree-structural state of an element that might be
  * used for selector matching eventually.
@@ -134,18 +134,21 @@ public:
     }
 
     mContains |= Flags::Attributes;
     if (aElement->HasID()) {
       mContains |= Flags::Id;
     }
 
     if (const nsAttrValue* classValue = aElement->GetClasses()) {
+      // FIXME(emilio): It's pretty unfortunate that this is only relevant for
+      // SVG, yet it's a somewhat expensive copy. We should be able to do
+      // better!
       mClass = *classValue;
-      mContains |= Flags::MaybeClass;
+      mContains |= Flags::Class;
     }
   }
 
   /**
    * Captures some other pseudo-class matching state not included in
    * EventStates.
    */
   void AddOtherPseudoClassState(Element* aElement);
@@ -189,17 +192,17 @@ public:
       }
     }
 
     return nullptr;
   }
 
   const nsAttrValue* DoGetClasses() const
   {
-    MOZ_ASSERT(HasAttrs());
+    MOZ_ASSERT(HasAny(Flags::Class));
     return &mClass;
   }
 
   bool IsInChromeDocument() const { return mIsInChromeDocument; }
   bool SupportsLangAttr() const { return mSupportsLangAttr; }
 
   bool HasAny(Flags aFlags) const { return bool(mContains & aFlags); }
 
--- a/servo/components/style/gecko/snapshot.rs
+++ b/servo/components/style/gecko/snapshot.rs
@@ -176,31 +176,31 @@ impl ElementSnapshot for GeckoElementSna
             None
         } else {
             Some(Atom::from(ptr))
         }
     }
 
     #[inline]
     fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
-        if !self.has_any(Flags::MaybeClass) {
+        if !self.has_any(Flags::Class) {
             return false;
         }
 
         snapshot_helpers::has_class(self.as_ptr(),
                                     name,
                                     case_sensitivity,
                                     bindings::Gecko_SnapshotClassOrClassList)
     }
 
     #[inline]
     fn each_class<F>(&self, callback: F)
         where F: FnMut(&Atom)
     {
-        if !self.has_any(Flags::MaybeClass) {
+        if !self.has_any(Flags::Class) {
             return;
         }
 
         snapshot_helpers::each_class(self.as_ptr(),
                                      callback,
                                      bindings::Gecko_SnapshotClassOrClassList)
     }