Bug 1258017 - Use an nsCOMPtr to hold onto the nsIStyleRule. r=dbaron
authorBobby Holley <bobbyholley@gmail.com>
Thu, 24 Mar 2016 18:26:46 -0700
changeset 290725 0df89ff664727fb2c28c21000a5692805fb26890
parent 290724 2f55fe267f0a232585e269aa29099ab664c074f8
child 290726 d478d82a9103926631bec33cf15fd315ee9429f0
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1258017
milestone48.0a1
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
@@ -1522,20 +1522,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(),
@@ -1551,19 +1547,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 {