Bug 1477533 - Use static const class variable to represent column-count: auto. r=heycam
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 20 Jul 2018 17:09:31 -0700
changeset 482897 dea3f75dbe56e748fb12a8d1247acd3d216d52e1
parent 482896 590299c07f06bcf6c900ad1cc853adfa34c80c70
child 482898 799227e35bc54f09d28b0891cd3e800b5d4a381f
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1477533
milestone63.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 1477533 - Use static const class variable to represent column-count: auto. r=heycam NS_STYLE_COLUMN_COUNT_UNLIMITED is unused, so I remove it. MozReview-Commit-ID: HLHLn9ZbkUY
layout/base/nsCSSFrameConstructor.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
servo/components/style/properties/gecko.mako.rs
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3298,17 +3298,17 @@ nsCSSFrameConstructor::ConstructFieldSet
       break;
     default: {
       MOZ_ASSERT(fieldsetContentDisplay->mDisplay == StyleDisplay::Block,
                  "bug in nsRuleNode::ComputeDisplayData?");
 
       nsContainerFrame* columnSetFrame = nullptr;
       RefPtr<ComputedStyle> innerSC = fieldsetContentStyle;
       const nsStyleColumn* columns = fieldsetContentStyle->StyleColumn();
-      if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO ||
+      if (columns->mColumnCount != nsStyleColumn::kColumnCountAuto ||
           columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
         columnSetFrame =
           NS_NewColumnSetFrame(mPresShell, fieldsetContentStyle,
                                nsFrameState(NS_FRAME_OWNS_ANON_BOXES));
         InitAndRestoreFrame(aState, content, parent, columnSetFrame);
         innerSC = mPresShell->StyleSet()->
           ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::columnContent,
                                              fieldsetContentStyle);
@@ -3920,17 +3920,17 @@ nsCSSFrameConstructor::ConstructFrameFro
             outerFrame = NS_NewGridContainerFrame(mPresShell, outerSC);
             InitAndRestoreFrame(aState, content, container, outerFrame);
             innerFrame = outerFrame;
             break;
           default: {
             nsContainerFrame* columnSetFrame = nullptr;
             RefPtr<ComputedStyle> innerSC = outerSC;
             const nsStyleColumn* columns = outerSC->StyleColumn();
-            if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO ||
+            if (columns->mColumnCount != nsStyleColumn::kColumnCountAuto ||
                 columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
               columnSetFrame =
                 NS_NewColumnSetFrame(mPresShell, outerSC,
                                      nsFrameState(NS_FRAME_OWNS_ANON_BOXES));
               InitAndRestoreFrame(aState, content, container, columnSetFrame);
               innerSC = mPresShell->StyleSet()->
                 ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::columnContent,
                                                    outerSC);
@@ -11010,17 +11010,17 @@ nsCSSFrameConstructor::ConstructBlock(ns
   // Create column wrapper if necessary
   nsContainerFrame* blockFrame = *aNewFrame;
   NS_ASSERTION((blockFrame->IsBlockFrame() || blockFrame->IsDetailsFrame()),
                "not a block frame nor a details frame?");
   nsContainerFrame* parent = aParentFrame;
   RefPtr<ComputedStyle> blockStyle = aComputedStyle;
   const nsStyleColumn* columns = aComputedStyle->StyleColumn();
 
-  if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO
+  if (columns->mColumnCount != nsStyleColumn::kColumnCountAuto
       || columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
     nsContainerFrame* columnSetFrame =
       NS_NewColumnSetFrame(mPresShell, aComputedStyle,
                            nsFrameState(NS_FRAME_OWNS_ANON_BOXES));
 
     InitAndRestoreFrame(aState, aContent, aParentFrame, columnSetFrame);
     blockStyle = mPresShell->StyleSet()->
       ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::columnContent,
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -1182,17 +1182,17 @@ nsComputedDOMStyle::DoGetColor()
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetColumnCount()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
 
   const nsStyleColumn* column = StyleColumn();
 
-  if (column->mColumnCount == NS_STYLE_COLUMN_COUNT_AUTO) {
+  if (column->mColumnCount == nsStyleColumn::kColumnCountAuto) {
     val->SetIdent(eCSSKeyword_auto);
   } else {
     val->SetNumber(column->mColumnCount);
   }
 
   return val.forget();
 }
 
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -974,20 +974,16 @@ enum class StyleWhiteSpace : uint8_t {
 
 // See nsStyleBreaks
 #define NS_STYLE_PAGE_BREAK_AUTO                0
 #define NS_STYLE_PAGE_BREAK_ALWAYS              1
 #define NS_STYLE_PAGE_BREAK_AVOID               2
 #define NS_STYLE_PAGE_BREAK_LEFT                3
 #define NS_STYLE_PAGE_BREAK_RIGHT               4
 
-// See nsStyleColumn
-#define NS_STYLE_COLUMN_COUNT_AUTO              0
-#define NS_STYLE_COLUMN_COUNT_UNLIMITED         (-1)
-
 #define NS_STYLE_COLUMN_FILL_AUTO               0
 #define NS_STYLE_COLUMN_FILL_BALANCE            1
 
 #define NS_STYLE_COLUMN_SPAN_NONE               0
 #define NS_STYLE_COLUMN_SPAN_ALL                1
 
 // See nsStyleUIReset
 #define NS_STYLE_IME_MODE_AUTO                  0
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -748,20 +748,20 @@ nsStyleXUL::CalcDifference(const nsStyle
   }
   return NS_STYLE_HINT_REFLOW;
 }
 
 // --------------------
 // nsStyleColumn
 //
 /* static */ const uint32_t nsStyleColumn::kMaxColumnCount;
+/* static */ const uint32_t nsStyleColumn::kColumnCountAuto;
 
 nsStyleColumn::nsStyleColumn(const nsPresContext* aContext)
-  : mColumnCount(NS_STYLE_COLUMN_COUNT_AUTO)
-  , mColumnWidth(eStyleUnit_Auto)
+  : mColumnWidth(eStyleUnit_Auto)
   , mColumnRuleColor(StyleComplexColor::CurrentColor())
   , mColumnRuleStyle(NS_STYLE_BORDER_STYLE_NONE)
   , mColumnFill(NS_STYLE_COLUMN_FILL_BALANCE)
   , mColumnSpan(NS_STYLE_COLUMN_SPAN_NONE)
   , mColumnRuleWidth((StaticPresData::Get()
                         ->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
   , mTwipsPerPixel(aContext->AppUnitsPerDevPixel())
 {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2801,23 +2801,24 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   explicit nsStyleColumn(const nsPresContext* aContext);
   nsStyleColumn(const nsStyleColumn& aSource);
   ~nsStyleColumn();
   void FinishStyle(nsPresContext*, const nsStyleColumn*) {}
   const static bool kHasFinishStyle = false;
 
   nsChangeHint CalcDifference(const nsStyleColumn& aNewData) const;
 
-  /**
-   * This is the maximum number of columns we can process. It's used in both
-   * nsColumnSetFrame and nsRuleNode.
-   */
+  // This is the maximum number of columns we can process. It's used in
+  // nsColumnSetFrame.
   static const uint32_t kMaxColumnCount = 1000;
 
-  uint32_t     mColumnCount; // NS_STYLE_COLUMN_COUNT_* or another integer
+  // This represents the value of column-count: auto.
+  static const uint32_t kColumnCountAuto = 0;
+
+  uint32_t mColumnCount = kColumnCountAuto;
   nsStyleCoord mColumnWidth; // coord, auto
 
   mozilla::StyleComplexColor mColumnRuleColor;
   uint8_t      mColumnRuleStyle;  // NS_STYLE_BORDER_STYLE_*
   uint8_t      mColumnFill;  // NS_STYLE_COLUMN_FILL_*
   uint8_t      mColumnSpan;  // NS_STYLE_COLUMN_SPAN_*
 
   void SetColumnRuleWidth(nscoord aWidth) {
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -5374,31 +5374,31 @@ clip-path
     }
 </%self:impl_trait>
 
 <%self:impl_trait style_struct_name="Column"
                   skip_longhands="column-count column-rule-width">
 
     #[allow(unused_unsafe)]
     pub fn set_column_count(&mut self, v: longhands::column_count::computed_value::T) {
-        use gecko_bindings::structs::{NS_STYLE_COLUMN_COUNT_AUTO, nsStyleColumn_kMaxColumnCount};
+        use gecko_bindings::structs::{nsStyleColumn_kColumnCountAuto, nsStyleColumn_kMaxColumnCount};
 
         self.gecko.mColumnCount = match v {
             ColumnCount::Integer(integer) => {
                 cmp::min(integer.0 as u32, unsafe { nsStyleColumn_kMaxColumnCount })
             },
-            ColumnCount::Auto => NS_STYLE_COLUMN_COUNT_AUTO
+            ColumnCount::Auto => nsStyleColumn_kColumnCountAuto
         };
     }
 
     ${impl_simple_copy('column_count', 'mColumnCount')}
 
     pub fn clone_column_count(&self) -> longhands::column_count::computed_value::T {
-        use gecko_bindings::structs::{NS_STYLE_COLUMN_COUNT_AUTO, nsStyleColumn_kMaxColumnCount};
-        if self.gecko.mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO {
+        use gecko_bindings::structs::{nsStyleColumn_kColumnCountAuto, nsStyleColumn_kMaxColumnCount};
+        if self.gecko.mColumnCount != nsStyleColumn_kColumnCountAuto {
             debug_assert!(self.gecko.mColumnCount >= 1 &&
                           self.gecko.mColumnCount <= nsStyleColumn_kMaxColumnCount);
             ColumnCount::Integer((self.gecko.mColumnCount as i32).into())
         } else {
             ColumnCount::Auto
         }
     }