Bug 1216332 - Remove framearena helpers from abstract frame classes and stop them from being instantiated. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 04 Nov 2015 20:57:35 +1100
changeset 271177 b3c86859606870fb2f30b4d574bbd74bca572964
parent 271176 717b8114f16a7ec15aa96a564221ca2ae5fd045f
child 271178 6e4244690d03b0c16fa671b9449b61176a9a99a8
push id29634
push usercbook@mozilla.com
push dateThu, 05 Nov 2015 10:59:26 +0000
treeherdermozilla-central@59c648a3f955 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1216332
milestone45.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 1216332 - Remove framearena helpers from abstract frame classes and stop them from being instantiated. r=dbaron
layout/forms/nsFormControlFrame.cpp
layout/forms/nsFormControlFrame.h
layout/generic/nsContainerFrame.cpp
layout/generic/nsContainerFrame.h
layout/generic/nsFrame.h
layout/generic/nsLeafFrame.cpp
layout/generic/nsLeafFrame.h
layout/generic/nsRubyContentFrame.cpp
layout/generic/nsRubyContentFrame.h
layout/generic/nsSplittableFrame.cpp
layout/generic/nsSplittableFrame.h
layout/mathml/nsMathMLContainerFrame.cpp
layout/mathml/nsMathMLContainerFrame.h
layout/svg/moz.build
layout/svg/nsSVGGradientFrame.cpp
layout/svg/nsSVGGradientFrame.h
layout/svg/nsSVGPaintServerFrame.cpp
layout/svg/nsSVGPaintServerFrame.h
--- a/layout/forms/nsFormControlFrame.cpp
+++ b/layout/forms/nsFormControlFrame.cpp
@@ -39,18 +39,16 @@ nsFormControlFrame::DestroyFrom(nsIFrame
   nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
   nsLeafFrame::DestroyFrom(aDestructRoot);
 }
 
 NS_QUERYFRAME_HEAD(nsFormControlFrame)
   NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsLeafFrame)
 
-NS_IMPL_FRAMEARENA_HELPERS(nsFormControlFrame)
-
 nscoord
 nsFormControlFrame::GetIntrinsicISize()
 {
   // Provide a reasonable default for sites that use an "auto" height.
   // Note that if you change this, you should change the values in forms.css
   // as well.  This is the 13px default width minus the 2px default border.
   return nsPresContext::CSSPixelsToAppUnits(13 - 2 * 2);
 }
--- a/layout/forms/nsFormControlFrame.h
+++ b/layout/forms/nsFormControlFrame.h
@@ -30,17 +30,17 @@ public:
 
   virtual bool IsFrameOfType(uint32_t aFlags) const override
   {
     return nsLeafFrame::IsFrameOfType(aFlags &
       ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
   }
 
   NS_DECL_QUERYFRAME
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsFormControlFrame)
 
   /** 
     * Respond to a gui event
     * @see nsIFrame::HandleEvent
     */
   virtual nsresult HandleEvent(nsPresContext* aPresContext, 
                                mozilla::WidgetGUIEvent* aEvent,
                                nsEventStatus* aEventStatus) override;
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -37,18 +37,16 @@
 #else
 #undef NOISY
 #endif
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::layout;
 
-NS_IMPL_FRAMEARENA_HELPERS(nsContainerFrame)
-
 nsContainerFrame::~nsContainerFrame()
 {
 }
 
 NS_QUERYFRAME_HEAD(nsContainerFrame)
   NS_QUERYFRAME_ENTRY(nsContainerFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsSplittableFrame)
 
--- a/layout/generic/nsContainerFrame.h
+++ b/layout/generic/nsContainerFrame.h
@@ -39,17 +39,17 @@ class FramePropertyTable;
 #endif
 
 /**
  * Implementation of a container frame.
  */
 class nsContainerFrame : public nsSplittableFrame
 {
 public:
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsContainerFrame)
   NS_DECL_QUERYFRAME_TARGET(nsContainerFrame)
   NS_DECL_QUERYFRAME
 
   // nsIFrame overrides
   virtual void Init(nsIContent*       aContent,
                     nsContainerFrame* aParent,
                     nsIFrame*         aPrevInFlow) override;
   virtual nsContainerFrame* GetContentInsertionFrame() override
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -73,32 +73,39 @@
 #define NS_FRAME_TRACE(_bits,_args)
 #define NS_FRAME_TRACE_IN(_method)
 #define NS_FRAME_TRACE_OUT(_method)
 #define NS_FRAME_TRACE_MSG(_bits,_args)
 #define NS_FRAME_TRACE_REFLOW_IN(_method)
 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status)
 #endif
 
-// Frame allocation boilerplate macros.  Every subclass of nsFrame
-// must define its own operator new and GetFrameId.  If they do
-// not, the per-frame recycler lists in nsPresArena will not work
-// correctly, with potentially catastrophic consequences (not enough
-// memory is allocated for a frame object).
+// Frame allocation boilerplate macros. Every subclass of nsFrame must
+// either use NS_{DECL,IMPL}_FRAMEARENA_HELPERS pair for allocating
+// memory correctly, or use NS_DECL_ABSTRACT_FRAME to declare a frame
+// class abstract and stop it from being instantiated. If a frame class
+// without its own operator new and GetFrameId gets instantiated, the
+// per-frame recycler lists in nsPresArena will not work correctly,
+// with potentially catastrophic consequences (not enough memory is
+// allocated for a frame object).
 
 #define NS_DECL_FRAMEARENA_HELPERS                                \
   void* operator new(size_t, nsIPresShell*) MOZ_MUST_OVERRIDE;    \
   virtual nsQueryFrame::FrameIID GetFrameId() override MOZ_MUST_OVERRIDE;
 
 #define NS_IMPL_FRAMEARENA_HELPERS(class)                         \
   void* class::operator new(size_t sz, nsIPresShell* aShell)      \
   { return aShell->AllocateFrame(nsQueryFrame::class##_id, sz); } \
   nsQueryFrame::FrameIID class::GetFrameId()                      \
   { return nsQueryFrame::class##_id; }
 
+#define NS_DECL_ABSTRACT_FRAME(class)                                   \
+  void* operator new(size_t, nsIPresShell*) MOZ_MUST_OVERRIDE = delete; \
+  virtual nsQueryFrame::FrameIID GetFrameId() override MOZ_MUST_OVERRIDE = 0;
+
 //----------------------------------------------------------------------
 
 struct nsBoxLayoutMetrics;
 struct nsRect;
 
 /**
  * Implementation of a simple frame that's not splittable and has no
  * child frames.
--- a/layout/generic/nsLeafFrame.cpp
+++ b/layout/generic/nsLeafFrame.cpp
@@ -9,18 +9,16 @@
 #include "nsPresContext.h"
 
 using namespace mozilla;
 
 nsLeafFrame::~nsLeafFrame()
 {
 }
 
-NS_IMPL_FRAMEARENA_HELPERS(nsLeafFrame)
-
 /* virtual */ nscoord
 nsLeafFrame::GetMinISize(nsRenderingContext *aRenderingContext)
 {
   nscoord result;
   DISPLAY_MIN_WIDTH(this, result);
 
   result = GetIntrinsicISize();
   return result;
--- a/layout/generic/nsLeafFrame.h
+++ b/layout/generic/nsLeafFrame.h
@@ -15,17 +15,17 @@
 /**
  * Abstract class that provides simple fixed-size layout for leaf objects
  * (e.g. images, form elements, etc.). Deriviations provide the implementation
  * of the GetDesiredSize method. The rendering method knows how to render
  * borders and backgrounds.
  */
 class nsLeafFrame : public nsFrame {
 public:
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsLeafFrame)
 
   // nsIFrame replacements
   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                 const nsRect&           aDirtyRect,
                                 const nsDisplayListSet& aLists) override {
     DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
     DisplayBorderBackgroundOutline(aBuilder, aLists);
   }
--- a/layout/generic/nsRubyContentFrame.cpp
+++ b/layout/generic/nsRubyContentFrame.cpp
@@ -10,23 +10,16 @@
 #include "nsPresContext.h"
 #include "nsStyleContext.h"
 #include "nsCSSAnonBoxes.h"
 
 using namespace mozilla;
 
 //----------------------------------------------------------------------
 
-// Frame class boilerplate
-// =======================
-
-NS_IMPL_FRAMEARENA_HELPERS(nsRubyContentFrame)
-
-//----------------------------------------------------------------------
-
 // nsRubyContentFrame Method Implementations
 // ======================================
 
 /* virtual */ bool
 nsRubyContentFrame::IsFrameOfType(uint32_t aFlags) const
 {
   if (aFlags & eBidiInlineContainer) {
     return false;
--- a/layout/generic/nsRubyContentFrame.h
+++ b/layout/generic/nsRubyContentFrame.h
@@ -11,17 +11,17 @@
 
 #include "nsInlineFrame.h"
 
 typedef nsInlineFrame nsRubyContentFrameSuper;
 
 class nsRubyContentFrame : public nsRubyContentFrameSuper
 {
 public:
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsRubyContentFrame)
 
   // nsIFrame overrides
   virtual bool IsFrameOfType(uint32_t aFlags) const override;
 
   // Indicates whether this is an "intra-level whitespace" frame, i.e.
   // an anonymous frame that was created to contain non-droppable
   // whitespaces directly inside a ruby level container. This impacts
   // ruby pairing behavior.
--- a/layout/generic/nsSplittableFrame.cpp
+++ b/layout/generic/nsSplittableFrame.cpp
@@ -9,18 +9,16 @@
  */
 
 #include "nsSplittableFrame.h"
 #include "nsContainerFrame.h"
 #include "nsIFrameInlines.h"
 
 using namespace mozilla;
 
-NS_IMPL_FRAMEARENA_HELPERS(nsSplittableFrame)
-
 void
 nsSplittableFrame::Init(nsIContent*       aContent,
                         nsContainerFrame* aParent,
                         nsIFrame*         aPrevInFlow)
 {
   nsFrame::Init(aContent, aParent, aPrevInFlow);
 
   if (aPrevInFlow) {
--- a/layout/generic/nsSplittableFrame.h
+++ b/layout/generic/nsSplittableFrame.h
@@ -13,17 +13,17 @@
 
 #include "mozilla/Attributes.h"
 #include "nsFrame.h"
 
 // Derived class that allows splitting
 class nsSplittableFrame : public nsFrame
 {
 public:
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsSplittableFrame)
 
   virtual void Init(nsIContent*       aContent,
                     nsContainerFrame* aParent,
                     nsIFrame*         aPrevInFlow) override;
   
   virtual nsSplittableType GetSplittableType() const override;
 
   virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -25,18 +25,16 @@
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 //
 // nsMathMLContainerFrame implementation
 //
 
-NS_IMPL_FRAMEARENA_HELPERS(nsMathMLContainerFrame)
-
 NS_QUERYFRAME_HEAD(nsMathMLContainerFrame)
   NS_QUERYFRAME_ENTRY(nsIMathMLFrame)
   NS_QUERYFRAME_ENTRY(nsMathMLContainerFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 // =============================================================================
 
 // error handlers
--- a/layout/mathml/nsMathMLContainerFrame.h
+++ b/layout/mathml/nsMathMLContainerFrame.h
@@ -33,17 +33,17 @@ class nsMathMLContainerFrame : public ns
 public:
   explicit nsMathMLContainerFrame(nsStyleContext* aContext)
     : nsContainerFrame(aContext)
     , mIntrinsicWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
   {}
 
   NS_DECL_QUERYFRAME_TARGET(nsMathMLContainerFrame)
   NS_DECL_QUERYFRAME
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsMathMLContainerFrame)
 
   // --------------------------------------------------------------------------
   // Overloaded nsMathMLFrame methods -- see documentation in nsIMathMLFrame.h
 
   NS_IMETHOD
   Stretch(nsRenderingContext& aRenderingContext,
           nsStretchDirection   aStretchDirection,
           nsBoundingMetrics&   aContainerSize,
--- a/layout/svg/moz.build
+++ b/layout/svg/moz.build
@@ -31,17 +31,16 @@ UNIFIED_SOURCES += [
     'nsSVGGFrame.cpp',
     'nsSVGGradientFrame.cpp',
     'nsSVGImageFrame.cpp',
     'nsSVGInnerSVGFrame.cpp',
     'nsSVGIntegrationUtils.cpp',
     'nsSVGMarkerFrame.cpp',
     'nsSVGMaskFrame.cpp',
     'nsSVGOuterSVGFrame.cpp',
-    'nsSVGPaintServerFrame.cpp',
     'nsSVGPathGeometryFrame.cpp',
     'nsSVGPatternFrame.cpp',
     'nsSVGStopFrame.cpp',
     'nsSVGSwitchFrame.cpp',
     'nsSVGUseFrame.cpp',
     'nsSVGUtils.cpp',
     'SVGFEContainerFrame.cpp',
     'SVGFEImageFrame.cpp',
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -50,18 +50,16 @@ private:
 
 nsSVGGradientFrame::nsSVGGradientFrame(nsStyleContext* aContext) :
   nsSVGGradientFrameBase(aContext),
   mLoopFlag(false),
   mNoHRefURI(false)
 {
 }
 
-NS_IMPL_FRAMEARENA_HELPERS(nsSVGGradientFrame)
-
 //----------------------------------------------------------------------
 // nsIFrame methods:
 
 nsresult
 nsSVGGradientFrame::AttributeChanged(int32_t         aNameSpaceID,
                                      nsIAtom*        aAttribute,
                                      int32_t         aModType)
 {
--- a/layout/svg/nsSVGGradientFrame.h
+++ b/layout/svg/nsSVGGradientFrame.h
@@ -40,17 +40,17 @@ typedef nsSVGPaintServerFrame nsSVGGradi
 class nsSVGGradientFrame : public nsSVGGradientFrameBase
 {
   typedef mozilla::gfx::ExtendMode ExtendMode;
 
 protected:
   explicit nsSVGGradientFrame(nsStyleContext* aContext);
 
 public:
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsSVGGradientFrame)
 
   // nsSVGPaintServerFrame methods:
   virtual already_AddRefed<gfxPattern>
     GetPaintServerPattern(nsIFrame* aSource,
                           const DrawTarget* aDrawTarget,
                           const gfxMatrix& aContextMatrix,
                           nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
                           float aGraphicOpacity,
deleted file mode 100644
--- a/layout/svg/nsSVGPaintServerFrame.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// Main header first:
-#include "nsSVGPaintServerFrame.h"
-
-// Keep others in (case-insensitive) order:
-#include "gfxContext.h"
-#include "nsSVGElement.h"
-
-NS_IMPL_FRAMEARENA_HELPERS(nsSVGPaintServerFrame)
--- a/layout/svg/nsSVGPaintServerFrame.h
+++ b/layout/svg/nsSVGPaintServerFrame.h
@@ -35,17 +35,17 @@ protected:
 
   explicit nsSVGPaintServerFrame(nsStyleContext* aContext)
     : nsSVGPaintServerFrameBase(aContext)
   {
     AddStateBits(NS_FRAME_IS_NONDISPLAY);
   }
 
 public:
-  NS_DECL_FRAMEARENA_HELPERS
+  NS_DECL_ABSTRACT_FRAME(nsSVGPaintServerFrame)
 
   /**
    * Constructs a gfxPattern of the paint server rendering.
    *
    * @param aContextMatrix The transform matrix that is currently applied to
    *   the gfxContext that is being drawn to. This is needed by SVG patterns so
    *   that surfaces of the correct size can be created. (SVG gradients are
    *   vector based, so it's not used there.)