Bug 388040 - Clean up nsSVGGeometryFrame: make constructor protected, put methods belonging to the same interface together and add interface comments. r+sr=tor
authorlongsonr@gmail.com
Tue, 17 Jul 2007 01:40:28 -0700
changeset 3557 cc2d6b62bcbcc731ffb60541e59cb4410faa2a0f
parent 3556 a232c160cbcf7c9a6a526a10431e07c64f1b949f
child 3558 63948bbfcbb02bec1725474a1ea83025e9628c4b
push idunknown
push userunknown
push dateunknown
bugs388040
milestone1.9a7pre
Bug 388040 - Clean up nsSVGGeometryFrame: make constructor protected, put methods belonging to the same interface together and add interface comments. r+sr=tor
layout/svg/base/src/nsSVGGeometryFrame.cpp
layout/svg/base/src/nsSVGGeometryFrame.h
--- a/layout/svg/base/src/nsSVGGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGGeometryFrame.cpp
@@ -45,72 +45,26 @@
 // nsISupports methods
 
 NS_INTERFACE_MAP_BEGIN(nsSVGGeometryFrame)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGGeometryFrameBase)
 
 //----------------------------------------------------------------------
-
-nsSVGGeometryFrame::nsSVGGeometryFrame(nsStyleContext* aContext)
-  : nsSVGGeometryFrameBase(aContext)
-{
-}
+// nsIFrame methods
 
 void
 nsSVGGeometryFrame::Destroy()
 {
   // Remove the properties before the frame goes away, since we need it for QI
   RemovePaintServerProperties();
   nsSVGGeometryFrameBase::Destroy();
 }
 
-void
-nsSVGGeometryFrame::RemovePaintServerProperties()
-{
-  DeleteProperty(nsGkAtoms::fill);
-  DeleteProperty(nsGkAtoms::stroke);
-  RemoveStateBits(NS_STATE_SVG_PSERVER_MASK);
-}
-
-nsSVGPaintServerFrame *
-nsSVGGeometryFrame::GetPaintServer(const nsStyleSVGPaint *aPaint)
-{
-  if (aPaint->mType != eStyleSVGPaintType_Server)
-    return nsnull;
-
-  nsIURI *uri;
-  uri = aPaint->mPaint.mPaintServer;
-  if (!uri)
-    return nsnull;
-
-  nsIFrame *result;
-  if (NS_FAILED(nsSVGUtils::GetReferencedFrame(&result, uri, mContent,
-                                               PresContext()->PresShell())))
-    return nsnull;
-
-  nsIAtom *type = result->GetType();
-  if (type != nsGkAtoms::svgLinearGradientFrame &&
-      type != nsGkAtoms::svgRadialGradientFrame &&
-      type != nsGkAtoms::svgPatternFrame)
-    return nsnull;
-
-  // Loop check for pattern
-  if (type == nsGkAtoms::svgPatternFrame &&
-      nsContentUtils::ContentIsDescendantOf(mContent, result->GetContent()))
-    return nsnull;
-
-  nsSVGPaintServerFrame *server =
-    static_cast<nsSVGPaintServerFrame*>(result);
-
-  server->AddObserver(this);
-  return server;
-}
-
 NS_IMETHODIMP
 nsSVGGeometryFrame::InitSVG()
 {
   AddStateBits(mParent->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD);
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -137,16 +91,19 @@ nsSVGGeometryFrame::DidSetStyleContext()
 {
   // One of the styles that might have been changed are the urls that
   // point to gradients, etc.  Drop our cached values to those
   RemovePaintServerProperties();
 
   return NS_OK;
 }
 
+//----------------------------------------------------------------------
+// nsISVGValueObserver methods:
+
 NS_IMETHODIMP
 nsSVGGeometryFrame::WillModifySVGObservable(nsISVGValue* observable,
 					   nsISVGValue::modificationType aModType)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -185,16 +142,58 @@ nsSVGGeometryFrame::DidModifySVGObservab
   }
 
   return NS_OK;
 }
 
 
 //----------------------------------------------------------------------
 
+void
+nsSVGGeometryFrame::RemovePaintServerProperties()
+{
+  DeleteProperty(nsGkAtoms::fill);
+  DeleteProperty(nsGkAtoms::stroke);
+  RemoveStateBits(NS_STATE_SVG_PSERVER_MASK);
+}
+
+nsSVGPaintServerFrame *
+nsSVGGeometryFrame::GetPaintServer(const nsStyleSVGPaint *aPaint)
+{
+  if (aPaint->mType != eStyleSVGPaintType_Server)
+    return nsnull;
+
+  nsIURI *uri;
+  uri = aPaint->mPaint.mPaintServer;
+  if (!uri)
+    return nsnull;
+
+  nsIFrame *result;
+  if (NS_FAILED(nsSVGUtils::GetReferencedFrame(&result, uri, mContent,
+                                               PresContext()->PresShell())))
+    return nsnull;
+
+  nsIAtom *type = result->GetType();
+  if (type != nsGkAtoms::svgLinearGradientFrame &&
+      type != nsGkAtoms::svgRadialGradientFrame &&
+      type != nsGkAtoms::svgPatternFrame)
+    return nsnull;
+
+  // Loop check for pattern
+  if (type == nsGkAtoms::svgPatternFrame &&
+      nsContentUtils::ContentIsDescendantOf(mContent, result->GetContent()))
+    return nsnull;
+
+  nsSVGPaintServerFrame *server =
+    static_cast<nsSVGPaintServerFrame*>(result);
+
+  server->AddObserver(this);
+  return server;
+}
+
 float
 nsSVGGeometryFrame::GetStrokeWidth()
 {
   nsSVGElement *ctx = static_cast<nsSVGElement*>
                                  (GetType() == nsGkAtoms::svgGlyphFrame ?
                                      mContent->GetParent() : mContent);
 
   return
--- a/layout/svg/base/src/nsSVGGeometryFrame.h
+++ b/layout/svg/base/src/nsSVGGeometryFrame.h
@@ -50,21 +50,23 @@ typedef nsFrame nsSVGGeometryFrameBase;
  * have geometry (circle, ellipse, line, polyline, polygon, path, and
  * glyph frames).  It knows how to convert the style information into
  * cairo context information and stores the fill/stroke paint
  * servers. */
 
 class nsSVGGeometryFrame : public nsSVGGeometryFrameBase,
                            public nsISVGValueObserver
 {
+protected:
+  nsSVGGeometryFrame(nsStyleContext *aContext) : nsSVGGeometryFrameBase(aContext) {}
+  NS_IMETHOD InitSVG();
+
 public:
-  nsSVGGeometryFrame(nsStyleContext *aContext);
+  // nsIFrame interface:
   virtual void Destroy();
-
-  // nsIFrame interface:
   NS_IMETHOD Init(nsIContent* aContent,
                   nsIFrame* aParent,
                   nsIFrame* aPrevInFlow);
   NS_IMETHOD DidSetStyleContext();
 
   virtual PRBool IsFrameOfType(PRUint32 aFlags) const
   {
     return nsSVGGeometryFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
@@ -111,18 +113,16 @@ public:
    */
   PRBool SetupCairoStroke(gfxContext *aContext, void **aClosure);
 
 protected:
   virtual nsresult UpdateGraphic(PRBool suppressInvalidation = PR_FALSE) = 0;
 
   nsSVGPaintServerFrame *GetPaintServer(const nsStyleSVGPaint *aPaint);
 
-  NS_IMETHOD InitSVG();
-
 private:
   nsresult GetStrokeDashArray(double **arr, PRUint32 *count);
   float GetStrokeDashoffset();
   void RemovePaintServerProperties();
 
   // Returns opacity that should be used in rendering this primitive.
   // In the general case the return value is just the passed opacity.
   // If we can avoid the expense of a specified group opacity, we