Bug 1258017 - Use an nsCOMPtr to hold onto the nsIStyleRule. r=dbaron
☠☠ backed out by 789ad2053247 ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Thu, 24 Mar 2016 18:26:46 -0700
changeset 323984 bceb57212824761be930e2a753df202ce14c5c5d
parent 323983 98b3c3a9c2732dd58a6e74c6d19deb53060dd5bf
child 323985 ece911f4b8e32df893b439d150599344913cb6c8
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1258017
milestone47.0a2
Bug 1258017 - Use an nsCOMPtr to hold onto the nsIStyleRule. r=dbaron
layout/style/nsRuleNode.cpp
layout/style/nsRuleNode.h
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1518,20 +1518,16 @@ nsRuleNode::nsRuleNode(nsPresContext* aC
 {
   MOZ_ASSERT(aContext);
   MOZ_ASSERT(IsRoot() == !aRule,
              "non-root rule nodes must have a rule");
 
   mChildren.asVoid = nullptr;
   MOZ_COUNT_CTOR(nsRuleNode);
 
-  if (mRule) {
-    mRule->AddRef();
-  }
-
   NS_ASSERTION(IsRoot() || GetLevel() == aLevel, "not enough bits");
   NS_ASSERTION(IsRoot() || IsImportantRule() == aIsImportant, "yikes");
   /* If IsRoot(), then aContext->StyleSet() is typically null at this
      point.  In any case, we don't want to treat the root rulenode as
      unused.  */
   if (!IsRoot()) {
     mParent->AddRef();
     MOZ_ASSERT(aContext->StyleSet()->IsGecko(),
@@ -1547,19 +1543,16 @@ nsRuleNode::nsRuleNode(nsPresContext* aC
              "must be only one rule at animation level");
 }
 
 nsRuleNode::~nsRuleNode()
 {
   MOZ_COUNT_DTOR(nsRuleNode);
   if (mStyleData.mResetData || mStyleData.mInheritedData)
     mStyleData.Destroy(mDependentBits, mPresContext);
-  if (mRule) {
-    mRule->Release();
-  }
 }
 
 nsRuleNode*
 nsRuleNode::Transition(nsIStyleRule* aRule, SheetType aLevel,
                        bool aIsImportantRule)
 {
 #ifdef DEBUG
   {
--- a/layout/style/nsRuleNode.h
+++ b/layout/style/nsRuleNode.h
@@ -415,17 +415,18 @@ public:
 private:
   nsPresContext* const mPresContext; // Our pres context.
 
   nsRuleNode* const mParent; // A pointer to the parent node in the tree.
                              // This enables us to walk backwards from the
                              // most specific rule matched to the least
                              // specific rule (which is the optimal order to
                              // use for lookups of style properties.
-  nsIStyleRule* const mRule; // [STRONG] A pointer to our specific rule.
+
+  const nsCOMPtr<nsIStyleRule> mRule; // A pointer to our specific rule.
 
   nsRuleNode* mNextSibling; // This value should be used only by the
                             // parent, since the parent may store
                             // children in a hash, which means this
                             // pointer is not meaningful.  Order of
                             // siblings is also not meaningful.
 
   struct Key {