Bug 1029180: Give nsStyleContext a private destructor & MOZ_FINAL, to make it less likely to be freed by anything other than refcounting. r=heycam
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 24 Jun 2014 11:00:57 -0700
changeset 190561 60853c0616842440962c6a92ef3ab84dc5d83645
parent 190560 70677e502001298c32972b3a447ea025741b5394
child 190562 a997d84b6925038c2a7d90839d561a788e50e743
push id27009
push userkwierso@gmail.com
push dateWed, 25 Jun 2014 01:13:54 +0000
treeherdermozilla-central@a19e0434ea52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1029180
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1029180: Give nsStyleContext a private destructor & MOZ_FINAL, to make it less likely to be freed by anything other than refcounting. r=heycam
layout/style/nsStyleContext.h
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -31,17 +31,17 @@ class nsPresContext;
  * by:
  *  1. the |nsIFrame|s that are using the style context and
  *  2. any *child* style contexts (this might be the reverse of
  *     expectation, but it makes sense in this case)
  * Style contexts participate in the mark phase of rule node garbage
  * collection.
  */
 
-class nsStyleContext
+class nsStyleContext MOZ_FINAL
 {
 public:
   /**
    * Create a new style context.
    * @param aParent  The parent of a style context is used for CSS
    *                 inheritance.  When the element or pseudo-element
    *                 this style context represents the style data of
    *                 inherits a CSS property, the value comes from the
@@ -62,17 +62,16 @@ public:
    *                 special cases where a child element's style may 
    *                 need to be modified based on its parent's display 
    *                 value.
    */
   nsStyleContext(nsStyleContext* aParent, nsIAtom* aPseudoTag,
                  nsCSSPseudoElements::Type aPseudoType,
                  nsRuleNode* aRuleNode,
                  bool aSkipParentDisplayBasedStyleFixup);
-  ~nsStyleContext();
 
   void* operator new(size_t sz, nsPresContext* aPresContext) CPP_THROW_NEW;
   void Destroy();
 
   nsrefcnt AddRef() {
     if (mRefCnt == UINT32_MAX) {
       NS_WARNING("refcount overflow, leaking object");
       return mRefCnt;
@@ -321,16 +320,19 @@ public:
   }
 
 #ifdef DEBUG
   void List(FILE* out, int32_t aIndent);
   static void AssertStyleStructMaxDifferenceValid();
 #endif
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~nsStyleContext();
+
   void AddChild(nsStyleContext* aChild);
   void RemoveChild(nsStyleContext* aChild);
 
   void ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup);
 
   // Helper function that GetStyleData and GetUniqueStyleData use.  Only
   // returns the structs we cache ourselves; never consults the ruletree.
   inline const void* GetCachedStyleData(nsStyleStructID aSID);