Bug 960277 - Part 2: Move nsFieldSetFrame declaration to nsFieldSetFrame.h. r=mats, a=lsblakk
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 16 Jan 2014 15:20:20 +1300
changeset 175093 f51c653bd79a42eb388a759b9c1e5d332e1aeb99
parent 175092 ac77f02b3dbe8c97efc3a8d70184f99887027317
child 175094 7832d9a8974ec14068ef11fe8a6d951881dbbf30
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, lsblakk
bugs960277
milestone28.0a2
Bug 960277 - Part 2: Move nsFieldSetFrame declaration to nsFieldSetFrame.h. r=mats, a=lsblakk
layout/forms/nsFieldSetFrame.cpp
layout/forms/nsFieldSetFrame.h
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -1,15 +1,16 @@
 /* -*- 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/. */
 
+#include "nsFieldSetFrame.h"
+
 #include "nsCSSAnonBoxes.h"
-#include "nsContainerFrame.h"
 #include "nsLegendFrame.h"
 #include "nsCSSRendering.h"
 #include <algorithm>
 #include "nsIFrame.h"
 #include "nsPresContext.h"
 #include "RestyleManager.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
@@ -17,132 +18,16 @@
 #include "nsRenderingContext.h"
 #include "nsIScrollableFrame.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Maybe.h"
 
 using namespace mozilla;
 using namespace mozilla::layout;
 
-class nsFieldSetFrame MOZ_FINAL : public nsContainerFrame {
-public:
-  NS_DECL_FRAMEARENA_HELPERS
-
-  nsFieldSetFrame(nsStyleContext* aContext);
-
-  NS_HIDDEN_(nscoord)
-    GetIntrinsicWidth(nsRenderingContext* aRenderingContext,
-                      nsLayoutUtils::IntrinsicWidthType);
-  virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext);
-  virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext);
-  virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
-                             nsSize aCBSize, nscoord aAvailableWidth,
-                             nsSize aMargin, nsSize aBorder, nsSize aPadding,
-                             uint32_t aFlags) MOZ_OVERRIDE;
-  virtual nscoord GetBaseline() const;
-
-  /**
-   * The area to paint box-shadows around.  It's the border rect except
-   * when there's a <legend> we offset the y-position to the center of it.
-   */
-  virtual nsRect VisualBorderRectRelativeToSelf() const MOZ_OVERRIDE {
-    nscoord topBorder = StyleBorder()->GetComputedBorderWidth(NS_SIDE_TOP);
-    nsRect r(nsPoint(0,0), GetSize());
-    if (topBorder < mLegendRect.height) {
-      nscoord yoff = (mLegendRect.height - topBorder) / 2;
-      r.y += yoff;
-      r.height -= yoff;
-    }
-    return r;
-  }
-
-  NS_IMETHOD Reflow(nsPresContext*           aPresContext,
-                    nsHTMLReflowMetrics&     aDesiredSize,
-                    const nsHTMLReflowState& aReflowState,
-                    nsReflowStatus&          aStatus);
-                               
-  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
-                                const nsRect&           aDirtyRect,
-                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;
-
-  void PaintBorderBackground(nsRenderingContext& aRenderingContext,
-    nsPoint aPt, const nsRect& aDirtyRect, uint32_t aBGFlags);
-
-  NS_IMETHOD AppendFrames(ChildListID    aListID,
-                          nsFrameList&   aFrameList);
-  NS_IMETHOD InsertFrames(ChildListID    aListID,
-                          nsIFrame*      aPrevFrame,
-                          nsFrameList&   aFrameList);
-  NS_IMETHOD RemoveFrame(ChildListID    aListID,
-                         nsIFrame*      aOldFrame);
-
-  virtual nsIAtom* GetType() const;
-  virtual bool IsFrameOfType(uint32_t aFlags) const
-  {
-    return nsContainerFrame::IsFrameOfType(aFlags &
-             ~nsIFrame::eCanContainOverflowContainers);
-  }
-  virtual nsIScrollableFrame* GetScrollTargetFrame() MOZ_OVERRIDE
-  {
-    return do_QueryFrame(GetInner());
-  }
-
-#ifdef ACCESSIBILITY  
-  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
-#endif
-
-#ifdef DEBUG
-  NS_IMETHOD SetInitialChildList(ChildListID    aListID,
-                                 nsFrameList&   aChildList);
-
-  NS_IMETHOD GetFrameName(nsAString& aResult) const {
-    return MakeFrameName(NS_LITERAL_STRING("FieldSet"), aResult);
-  }
-#endif
-
-protected:
-
-  /**
-   * Return the anonymous frame that contains all descendants except
-   * the legend frame.  This is currently always a block frame with
-   * pseudo nsCSSAnonBoxes::fieldsetContent -- this may change in the
-   * future when we add support for CSS overflow for <fieldset>.
-   */
-  nsIFrame* GetInner() const
-  {
-    nsIFrame* last = mFrames.LastChild();
-    if (last &&
-        last->StyleContext()->GetPseudo() == nsCSSAnonBoxes::fieldsetContent) {
-      return last;
-    }
-    MOZ_ASSERT(mFrames.LastChild() == mFrames.FirstChild());
-    return nullptr;
-  }
-
-  /**
-   * Return the frame that represents the legend if any.  This may be
-   * a nsLegendFrame or a nsHTMLScrollFrame with the nsLegendFrame as the
-   * scrolled frame (aka content insertion frame).
-   */
-  nsIFrame* GetLegend() const
-  {
-    if (mFrames.FirstChild() == GetInner()) {
-      MOZ_ASSERT(mFrames.LastChild() == mFrames.FirstChild());
-      return nullptr;
-    }
-    MOZ_ASSERT(mFrames.FirstChild() &&
-               mFrames.FirstChild()->GetContentInsertionFrame()->GetType() ==
-                 nsGkAtoms::legendFrame);
-    return mFrames.FirstChild();
-  }
-
-  nsRect    mLegendRect;
-  nscoord   mLegendSpace;
-};
-
 nsIFrame*
 NS_NewFieldSetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsFieldSetFrame(aContext);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsFieldSetFrame)
 
@@ -164,16 +49,54 @@ nsFieldSetFrame::SetInitialChildList(Chi
                                      nsFrameList&   aChildList)
 {
   nsresult rv = nsContainerFrame::SetInitialChildList(kPrincipalList, aChildList);
   MOZ_ASSERT(GetInner());
   return rv;
 }
 #endif
 
+nsRect
+nsFieldSetFrame::VisualBorderRectRelativeToSelf() const
+{
+  nscoord topBorder = StyleBorder()->GetComputedBorderWidth(NS_SIDE_TOP);
+  nsRect r(nsPoint(0,0), GetSize());
+  if (topBorder < mLegendRect.height) {
+    nscoord yoff = (mLegendRect.height - topBorder) / 2;
+    r.y += yoff;
+    r.height -= yoff;
+  }
+  return r;
+}
+
+nsIFrame*
+nsFieldSetFrame::GetInner() const
+{
+  nsIFrame* last = mFrames.LastChild();
+  if (last &&
+      last->StyleContext()->GetPseudo() == nsCSSAnonBoxes::fieldsetContent) {
+    return last;
+  }
+  MOZ_ASSERT(mFrames.LastChild() == mFrames.FirstChild());
+  return nullptr;
+}
+
+nsIFrame*
+nsFieldSetFrame::GetLegend() const
+{
+  if (mFrames.FirstChild() == GetInner()) {
+    MOZ_ASSERT(mFrames.LastChild() == mFrames.FirstChild());
+    return nullptr;
+  }
+  MOZ_ASSERT(mFrames.FirstChild() &&
+             mFrames.FirstChild()->GetContentInsertionFrame()->GetType() ==
+               nsGkAtoms::legendFrame);
+  return mFrames.FirstChild();
+}
+
 class nsDisplayFieldSetBorderBackground : public nsDisplayItem {
 public:
   nsDisplayFieldSetBorderBackground(nsDisplayListBuilder* aBuilder,
                                     nsFieldSetFrame* aFrame)
     : nsDisplayItem(aBuilder, aFrame) {
     MOZ_COUNT_CTOR(nsDisplayFieldSetBorderBackground);
   }
 #ifdef NS_BUILD_REFCNT_LOGGING
new file mode 100644
--- /dev/null
+++ b/layout/forms/nsFieldSetFrame.h
@@ -0,0 +1,99 @@
+/* -*- 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/. */
+
+#ifndef nsFieldSetFrame_h___
+#define nsFieldSetFrame_h___
+
+#include "nsContainerFrame.h"
+
+class nsFieldSetFrame MOZ_FINAL : public nsContainerFrame
+{
+public:
+  NS_DECL_FRAMEARENA_HELPERS
+
+  nsFieldSetFrame(nsStyleContext* aContext);
+
+  NS_HIDDEN_(nscoord)
+    GetIntrinsicWidth(nsRenderingContext* aRenderingContext,
+                      nsLayoutUtils::IntrinsicWidthType);
+  virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext);
+  virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext);
+  virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
+                             nsSize aCBSize, nscoord aAvailableWidth,
+                             nsSize aMargin, nsSize aBorder, nsSize aPadding,
+                             uint32_t aFlags) MOZ_OVERRIDE;
+  virtual nscoord GetBaseline() const;
+
+  /**
+   * The area to paint box-shadows around.  It's the border rect except
+   * when there's a <legend> we offset the y-position to the center of it.
+   */
+  virtual nsRect VisualBorderRectRelativeToSelf() const MOZ_OVERRIDE;
+
+  NS_IMETHOD Reflow(nsPresContext*           aPresContext,
+                    nsHTMLReflowMetrics&     aDesiredSize,
+                    const nsHTMLReflowState& aReflowState,
+                    nsReflowStatus&          aStatus);
+                               
+  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
+                                const nsRect&           aDirtyRect,
+                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;
+
+  void PaintBorderBackground(nsRenderingContext& aRenderingContext,
+    nsPoint aPt, const nsRect& aDirtyRect, uint32_t aBGFlags);
+
+  NS_IMETHOD AppendFrames(ChildListID    aListID,
+                          nsFrameList&   aFrameList);
+  NS_IMETHOD InsertFrames(ChildListID    aListID,
+                          nsIFrame*      aPrevFrame,
+                          nsFrameList&   aFrameList);
+  NS_IMETHOD RemoveFrame(ChildListID    aListID,
+                         nsIFrame*      aOldFrame);
+
+  virtual nsIAtom* GetType() const;
+  virtual bool IsFrameOfType(uint32_t aFlags) const
+  {
+    return nsContainerFrame::IsFrameOfType(aFlags &
+             ~nsIFrame::eCanContainOverflowContainers);
+  }
+  virtual nsIScrollableFrame* GetScrollTargetFrame() MOZ_OVERRIDE
+  {
+    return do_QueryFrame(GetInner());
+  }
+
+#ifdef ACCESSIBILITY  
+  virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
+#endif
+
+#ifdef DEBUG
+  NS_IMETHOD SetInitialChildList(ChildListID    aListID,
+                                 nsFrameList&   aChildList);
+
+  NS_IMETHOD GetFrameName(nsAString& aResult) const {
+    return MakeFrameName(NS_LITERAL_STRING("FieldSet"), aResult);
+  }
+#endif
+
+  /**
+   * Return the anonymous frame that contains all descendants except
+   * the legend frame.  This is currently always a block frame with
+   * pseudo nsCSSAnonBoxes::fieldsetContent -- this may change in the
+   * future when we add support for CSS overflow for <fieldset>.
+   */
+  nsIFrame* GetInner() const;
+
+  /**
+   * Return the frame that represents the legend if any.  This may be
+   * a nsLegendFrame or a nsHTMLScrollFrame with the nsLegendFrame as the
+   * scrolled frame (aka content insertion frame).
+   */
+  nsIFrame* GetLegend() const;
+
+protected:
+  nsRect    mLegendRect;
+  nscoord   mLegendSpace;
+};
+
+#endif // nsFieldSetFrame_h___