Bug 1511730 patch 2 - Refactor the frame state group macros so that there's a unique header for every group. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Wed, 05 Dec 2018 14:27:37 +0000
changeset 508650 6faca87a75497a3f775feafdac94b6043e83b1eb
parent 508649 3984125e9c657d218e575ef757200e573aa310e0
child 508651 6fd0a7cc9a43b818853c98f2134745a517d706fb
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1511730
milestone65.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 1511730 patch 2 - Refactor the frame state group macros so that there's a unique header for every group. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D13778
layout/generic/nsFrameState.cpp
layout/generic/nsFrameStateBits.h
--- a/layout/generic/nsFrameState.cpp
+++ b/layout/generic/nsFrameState.cpp
@@ -36,33 +36,33 @@ nsCString GetFrameState(nsIFrame* aFrame
 
   nsFrameState state = aFrame->GetStateBits();
 
   if (state == nsFrameState(0)) {
     result.Assign('0');
     return result;
   }
 
-#define FRAME_STATE_GROUP(name_, class_)                                       \
+#define FRAME_STATE_GROUP_CLASS(name_, class_)                                 \
   {                                                                            \
     class_* frame = do_QueryFrame(aFrame);                                     \
     if (frame && (groups.IsEmpty() || strcmp(groups.LastElement(), #name_))) { \
       groups.AppendElement(#name_);                                            \
     }                                                                          \
   }
 #define FRAME_STATE_BIT(group_, value_, name_)                            \
   if ((state & NS_FRAME_STATE_BIT(value_)) && groups.Contains(#group_)) { \
     if (!result.IsEmpty()) {                                              \
       result.InsertLiteral(" | ", 0);                                     \
     }                                                                     \
     result.InsertLiteral(#name_, 0);                                      \
     state = state & ~NS_FRAME_STATE_BIT(value_);                          \
   }
 #include "nsFrameStateBits.h"
-#undef FRAME_STATE_GROUP
+#undef FRAME_STATE_GROUP_CLASS
 #undef FRAME_STATE_BIT
 
   if (state) {
     result.AppendPrintf(" | 0x%0" PRIx64, static_cast<uint64_t>(state));
   }
 
   return result;
 }
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -7,52 +7,64 @@
 /* a list of all frame state bits, for preprocessing */
 
 /******
 
   This file contains definitions for frame state bits -- values used
   in nsIFrame::mState -- and groups of frame state bits and which
   classes they apply to.
 
-  There are two macros that can be defined before #including this
+  There are three macros that can be defined before #including this
   file:
 
-  FRAME_STATE_GROUP(name_, class_)
+  FRAME_STATE_GROUP_NAME(name_)
 
     This denotes the existence of a named group of frame state bits.
-    name_ is the name of the group and class_ is the name of a frame
-    class that uses the frame state bits that are a part of the group.
 
     The main group of frame state bits is named "Generic" and is
     defined to apply to nsIFrame, i.e. all frames.  All of the global
     frame state bits -- bits 0..19 and 32..59 -- are in this group.
 
+  FRAME_STATE_GROUP_CLASS(group_, class_)
+    class_ is the name of a frame class that uses the frame state bits
+    that are a part of the group.
+
   FRAME_STATE_BIT(group_, value_, name_)
 
     This denotes the existence of a frame state bit.  group_ indicates
     which group the bit belongs to, value_ is the bit number (0..63),
     and name_ is the name of the frame state bit constant.
 
   Note that if you add a new frame state group, you'll need to #include
   the header for its frame classes in nsFrameState.cpp and, if they don't
   already, add nsQueryFrame implementations (which can be DEBUG-only) to
   the frame classes.
 
  ******/
 
-#ifndef FRAME_STATE_GROUP
-#define FRAME_STATE_GROUP(name_, class_) /* nothing */
-#define DEFINED_FRAME_STATE_GROUP
+#ifndef FRAME_STATE_GROUP_NAME
+#define FRAME_STATE_GROUP_NAME(name_) /* nothing */
+#define DEFINED_FRAME_STATE_GROUP_NAME
+#endif
+
+#ifndef FRAME_STATE_GROUP_CLASS
+#define FRAME_STATE_GROUP_CLASS(name_, class_) /* nothing */
+#define DEFINED_FRAME_STATE_GROUP_CLASS
 #endif
 
 #ifndef FRAME_STATE_BIT
 #define FRAME_STATE_BIT(group_, value_, name_) /* nothing */
 #define DEFINED_FRAME_STATE_BIT
 #endif
 
+// Helper macro for the common case of a single class
+#define FRAME_STATE_GROUP(name_, class_) \
+  FRAME_STATE_GROUP_NAME(name_)          \
+  FRAME_STATE_GROUP_CLASS(name_, class_)
+
 // == Frame state bits that apply to all frames ===============================
 
 FRAME_STATE_GROUP(Generic, nsIFrame)
 
 // This bit is set when the frame is actively being reflowed. It is set in many
 // frames' Reflow() by calling MarkInReflow() and unset in DidReflow().
 FRAME_STATE_BIT(Generic, 0, NS_FRAME_IN_REFLOW)
 
@@ -369,18 +381,19 @@ FRAME_STATE_BIT(GridContainer, 26, NS_ST
 // The container contains one or more items subgridded in its block axis.
 FRAME_STATE_BIT(GridContainer, 27, NS_STATE_GRID_HAS_ROW_SUBGRID_ITEM)
 
 // We've merged some OverflowList children since last reflow.
 FRAME_STATE_BIT(GridContainer, 28, NS_STATE_GRID_HAS_CHILD_NIFS)
 
 // == Frame state bits that apply to SVG frames ===============================
 
-FRAME_STATE_GROUP(SVG, nsSVGDisplayableFrame)
-FRAME_STATE_GROUP(SVG, nsSVGContainerFrame)
+FRAME_STATE_GROUP_NAME(SVG)
+FRAME_STATE_GROUP_CLASS(SVG, nsSVGDisplayableFrame)
+FRAME_STATE_GROUP_CLASS(SVG, nsSVGContainerFrame)
 
 FRAME_STATE_BIT(SVG, 20, NS_STATE_IS_OUTER_SVG)
 
 // If this bit is set, we are a <clipPath> element or descendant.
 FRAME_STATE_BIT(SVG, 21, NS_STATE_SVG_CLIPPATH_CHILD)
 
 // For SVG text, the NS_FRAME_IS_DIRTY and NS_FRAME_HAS_DIRTY_CHILDREN bits
 // indicate that our anonymous block child needs to be reflowed, and that
@@ -655,18 +668,19 @@ FRAME_STATE_BIT(TableCell, 31, NS_TABLE_
 // Bits 28-31 on nsTableColFrames are used to store the column type.
 
 // == Frame state bits that apply to table column group frames ================
 
 // Bits 30-31 on nsTableColGroupFrames are used to store the column type.
 
 // == Frame state bits that apply to table rows and table row group frames ====
 
-FRAME_STATE_GROUP(TableRowAndRowGroup, nsTableRowFrame)
-FRAME_STATE_GROUP(TableRowAndRowGroup, nsTableRowGroupFrame)
+FRAME_STATE_GROUP_NAME(TableRowAndRowGroup)
+FRAME_STATE_GROUP_CLASS(TableRowAndRowGroup, nsTableRowFrame)
+FRAME_STATE_GROUP_CLASS(TableRowAndRowGroup, nsTableRowGroupFrame)
 
 // see nsTableRowGroupFrame::InitRepeatedFrame
 FRAME_STATE_BIT(TableRowAndRowGroup, 28, NS_REPEATED_ROW_OR_ROWGROUP)
 
 // == Frame state bits that apply to table row frames =========================
 
 FRAME_STATE_GROUP(TableRow, nsTableRowFrame)
 
@@ -685,17 +699,24 @@ FRAME_STATE_BIT(TableRowGroup, 30, NS_RO
 
 // thead or tfoot should be repeated on every printed page
 FRAME_STATE_BIT(TableRowGroup, 31, NS_ROWGROUP_REPEATABLE)
 
 FRAME_STATE_GROUP(Table, nsTableFrame)
 
 FRAME_STATE_BIT(Table, 28, NS_TABLE_PART_HAS_FIXED_BACKGROUND)
 
-#ifdef DEFINED_FRAME_STATE_GROUP
-#undef DEFINED_FRAME_STATE_GROUP
 #undef FRAME_STATE_GROUP
+
+#ifdef DEFINED_FRAME_STATE_GROUP_NAME
+#undef DEFINED_FRAME_STATE_GROUP_NAME
+#undef FRAME_STATE_GROUP_NAME
+#endif
+
+#ifdef DEFINED_FRAME_STATE_GROUP_CLASS
+#undef DEFINED_FRAME_STATE_GROUP_CLASS
+#undef FRAME_STATE_GROUP_CLASS
 #endif
 
 #ifdef DEFINED_FRAME_STATE_BIT
 #undef DEFINED_FRAME_STATE_BIT
 #undef FRAME_STATE_BIT
 #endif