Bug 1075336 - Fix lifetime management of CounterStyle. r=dbaron, a=sledru
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 02 Oct 2014 14:24:32 -0400
changeset 216915 d79568d581e6
parent 216914 fa58aaa6863e
child 216916 d8ebbb47a75e
push id3966
push userryanvm@gmail.com
push date2014-10-02 18:27 +0000
treeherdermozilla-beta@d79568d581e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, sledru
bugs1075336
milestone33.0
Bug 1075336 - Fix lifetime management of CounterStyle. r=dbaron, a=sledru
layout/style/CounterStyleManager.cpp
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -1910,16 +1910,23 @@ InvalidateOldStyle(const nsSubstring& aK
         toBeUpdated = true;
         style->ResetCachedData();
       }
     }
   }
   data->mChanged = data->mChanged || toBeUpdated || toBeRemoved;
   if (toBeRemoved) {
     if (aStyle->IsDependentStyle()) {
+      if (aStyle->IsCustomStyle()) {
+        // Since |aStyle| is being removed from mCacheTable, it won't be visited
+        // by our post-removal InvalidateDependentData() traversal. So, we have
+        // to give it a manual ResetDependentData() call. (This only really
+        // matters if something else is holding a reference & keeping it alive.)
+        static_cast<CustomCounterStyle*>(aStyle.get())->ResetDependentData();
+      }
       // The object has to be held here so that it will not be released
       // before all pointers that refer to it are reset. It will be
       // released when the MarkAndCleanData goes out of scope at the end
       // of NotifyRuleChanged().
       data->mToBeRemoved.AppendElement(aStyle);
     }
     return PL_DHASH_REMOVE;
   }