Bug 1339298 - Add boilerplate code for CSS3 multicol column-span parsing and define pref 'layout.css.column-span.enabled' to toggle it. r?dholbert draft
authorNeerja Pancholi <npancholi@mozilla.com>
Mon, 13 Feb 2017 16:57:33 -0800
changeset 494296 6b27cedd3714037c3cb2cebd725185adacd9f051
parent 494079 517c553ad64746c479456653ce11b04ab8e4977f
child 548078 0620af1690e6581d6e1504f13417d51fd1af5cbe
push id48008
push userbmo:npancholi@mozilla.com
push dateTue, 07 Mar 2017 00:59:20 +0000
reviewersdholbert
bugs1339298
milestone54.0a1
Bug 1339298 - Add boilerplate code for CSS3 multicol column-span parsing and define pref 'layout.css.column-span.enabled' to toggle it. r?dholbert MozReview-Commit-ID: 6aSlRhcKm8i
layout/style/nsCSSPropList.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSProps.h
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
layout/style/nsComputedDOMStylePropertyList.h
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/style/test/property_database.js
modules/libpref/init/all.js
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -1548,16 +1548,26 @@ CSS_PROP_COLUMN(
     CSS_PROPERTY_PARSE_VALUE |
         CSS_PROPERTY_VALUE_NONNEGATIVE,
     "",
     VARIANT_HKL | VARIANT_CALC,
     kBorderWidthKTable,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_Custom)
 CSS_PROP_COLUMN(
+    column-span,
+    column_span,
+    ColumnSpan,
+    CSS_PROPERTY_PARSE_VALUE,
+    "layout.css.column-span.enabled",
+    VARIANT_HK,
+    kColumnSpanKTable,
+    CSS_PROP_NO_OFFSET,
+    eStyleAnimType_Discrete)
+CSS_PROP_COLUMN(
     column-width,
     column_width,
     ColumnWidth,
     CSS_PROPERTY_PARSE_VALUE |
         CSS_PROPERTY_VALUE_NONNEGATIVE,
     "",
     VARIANT_AHL | VARIANT_CALC,
     nullptr,
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -2430,16 +2430,22 @@ const KTableEntry nsCSSProps::kColorInte
 };
 
 const KTableEntry nsCSSProps::kColumnFillKTable[] = {
   { eCSSKeyword_auto, NS_STYLE_COLUMN_FILL_AUTO },
   { eCSSKeyword_balance, NS_STYLE_COLUMN_FILL_BALANCE },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
+const KTableEntry nsCSSProps::kColumnSpanKTable[] = {
+  { eCSSKeyword_all, NS_STYLE_COLUMN_SPAN_ALL },
+  { eCSSKeyword_none, NS_STYLE_COLUMN_SPAN_NONE },
+  { eCSSKeyword_UNKNOWN, -1 }
+};
+
 static inline bool
 IsKeyValSentinel(const KTableEntry& aTableEntry)
 {
   return aTableEntry.mKeyword == eCSSKeyword_UNKNOWN &&
          aTableEntry.mValue == -1;
 }
 
 int32_t
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -731,16 +731,17 @@ public:
   static const KTableEntry kStrokeLinejoinKTable[];
   static const KTableEntry kStrokeContextValueKTable[];
   static const KTableEntry kVectorEffectKTable[];
   static const KTableEntry kTextAnchorKTable[];
   static const KTableEntry kTextRenderingKTable[];
   static const KTableEntry kColorAdjustKTable[];
   static const KTableEntry kColorInterpolationKTable[];
   static const KTableEntry kColumnFillKTable[];
+  static const KTableEntry kColumnSpanKTable[];
   static const KTableEntry kBoxPropSourceKTable[];
   static const KTableEntry kBoxShadowTypeKTable[];
   static const KTableEntry kBoxSizingKTable[];
   static const KTableEntry kCaptionSideKTable[];
   // Not const because we modify its entries when the pref
   // "layout.css.float-logical-values.enabled" changes:
   static KTableEntry kClearKTable[];
   static const KTableEntry kColorKTable[];
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -1214,16 +1214,25 @@ nsComputedDOMStyle::DoGetColumnFill()
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(
     nsCSSProps::ValueToKeywordEnum(StyleColumn()->mColumnFill,
                                    nsCSSProps::kColumnFillKTable));
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
+nsComputedDOMStyle::DoGetColumnSpan()
+{
+  RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
+  val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleColumn()->mColumnSpan,
+                                               nsCSSProps::kColumnSpanKTable));
+  return val.forget();
+}
+
+already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetColumnRuleWidth()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetAppUnits(StyleColumn()->GetComputedColumnRuleWidth());
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -508,16 +508,17 @@ private:
   already_AddRefed<CSSValue> DoGetUserInput();
   already_AddRefed<CSSValue> DoGetUserModify();
   already_AddRefed<CSSValue> DoGetUserSelect();
   already_AddRefed<CSSValue> DoGetWindowDragging();
 
   /* Column properties */
   already_AddRefed<CSSValue> DoGetColumnCount();
   already_AddRefed<CSSValue> DoGetColumnFill();
+  already_AddRefed<CSSValue> DoGetColumnSpan();
   already_AddRefed<CSSValue> DoGetColumnWidth();
   already_AddRefed<CSSValue> DoGetColumnGap();
   already_AddRefed<CSSValue> DoGetColumnRuleWidth();
   already_AddRefed<CSSValue> DoGetColumnRuleStyle();
   already_AddRefed<CSSValue> DoGetColumnRuleColor();
 
   /* CSS Transitions */
   already_AddRefed<CSSValue> DoGetTransitionProperty();
--- a/layout/style/nsComputedDOMStylePropertyList.h
+++ b/layout/style/nsComputedDOMStylePropertyList.h
@@ -108,16 +108,17 @@ COMPUTED_STYLE_PROP(color,              
 COMPUTED_STYLE_PROP(color_adjust,                  ColorAdjust)
 COMPUTED_STYLE_PROP(column_count,                  ColumnCount)
 COMPUTED_STYLE_PROP(column_fill,                   ColumnFill)
 COMPUTED_STYLE_PROP(column_gap,                    ColumnGap)
 //// COMPUTED_STYLE_PROP(column_rule,              ColumnRule)
 COMPUTED_STYLE_PROP(column_rule_color,             ColumnRuleColor)
 COMPUTED_STYLE_PROP(column_rule_style,             ColumnRuleStyle)
 COMPUTED_STYLE_PROP(column_rule_width,             ColumnRuleWidth)
+COMPUTED_STYLE_PROP(column_span,                   ColumnSpan)
 COMPUTED_STYLE_PROP(column_width,                  ColumnWidth)
 COMPUTED_STYLE_PROP(contain,                       Contain)
 COMPUTED_STYLE_PROP(content,                       Content)
 COMPUTED_STYLE_PROP(counter_increment,             CounterIncrement)
 COMPUTED_STYLE_PROP(counter_reset,                 CounterReset)
 COMPUTED_STYLE_PROP(cursor,                        Cursor)
 COMPUTED_STYLE_PROP(direction,                     Direction)
 COMPUTED_STYLE_PROP(display,                       Display)
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -9283,16 +9283,23 @@ nsRuleNode::ComputeColumnData(void* aSta
 
   // column-fill: enum
   SetValue(*aRuleData->ValueForColumnFill(),
            column->mColumnFill, conditions,
            SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
            parent->mColumnFill,
            NS_STYLE_COLUMN_FILL_BALANCE);
 
+  // column-span: enum
+  SetValue(*aRuleData->ValueForColumnSpan(),
+           column->mColumnSpan, conditions,
+           SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
+           parent->mColumnSpan,
+           NS_STYLE_COLUMN_SPAN_NONE);
+
   COMPUTE_END_RESET(Column, column)
 }
 
 static void
 SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint,
             nsPresContext* aPresContext, nsStyleContext *aContext,
             nsStyleSVGPaint& aResult, nsStyleSVGPaintType aInitialPaintType,
             RuleNodeCacheConditions& aConditions)
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -1031,16 +1031,19 @@ enum class StyleGridTrackBreadth : uint8
 
 // 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
 #define NS_STYLE_IME_MODE_NORMAL                1
 #define NS_STYLE_IME_MODE_ACTIVE                2
 #define NS_STYLE_IME_MODE_DISABLED              3
 #define NS_STYLE_IME_MODE_INACTIVE              4
 
 // See nsStyleGradient
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -780,16 +780,17 @@ nsStyleXUL::CalcDifference(const nsStyle
 
 nsStyleColumn::nsStyleColumn(const nsPresContext* aContext)
   : mColumnCount(NS_STYLE_COLUMN_COUNT_AUTO)
   , mColumnWidth(eStyleUnit_Auto)
   , mColumnGap(eStyleUnit_Normal)
   , 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())
 {
   MOZ_COUNT_CTOR(nsStyleColumn);
 }
 
 nsStyleColumn::~nsStyleColumn()
@@ -799,28 +800,30 @@ nsStyleColumn::~nsStyleColumn()
 
 nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource)
   : mColumnCount(aSource.mColumnCount)
   , mColumnWidth(aSource.mColumnWidth)
   , mColumnGap(aSource.mColumnGap)
   , mColumnRuleColor(aSource.mColumnRuleColor)
   , mColumnRuleStyle(aSource.mColumnRuleStyle)
   , mColumnFill(aSource.mColumnFill)
+  , mColumnSpan(aSource.mColumnSpan)
   , mColumnRuleWidth(aSource.mColumnRuleWidth)
   , mTwipsPerPixel(aSource.mTwipsPerPixel)
 {
   MOZ_COUNT_CTOR(nsStyleColumn);
 }
 
 nsChangeHint
 nsStyleColumn::CalcDifference(const nsStyleColumn& aNewData) const
 {
   if ((mColumnWidth.GetUnit() == eStyleUnit_Auto)
       != (aNewData.mColumnWidth.GetUnit() == eStyleUnit_Auto) ||
-      mColumnCount != aNewData.mColumnCount) {
+      mColumnCount != aNewData.mColumnCount ||
+      mColumnSpan != aNewData.mColumnSpan) {
     // We force column count changes to do a reframe, because it's tricky to handle
     // some edge cases where the column count gets smaller and content overflows.
     // XXX not ideal
     return nsChangeHint_ReconstructFrame;
   }
 
   if (mColumnWidth != aNewData.mColumnWidth ||
       mColumnGap != aNewData.mColumnGap ||
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3567,16 +3567,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
 
   uint32_t     mColumnCount; // [reset] see nsStyleConsts.h
   nsStyleCoord mColumnWidth; // [reset] coord, auto
   nsStyleCoord mColumnGap;   // [reset] coord, normal
 
   mozilla::StyleComplexColor mColumnRuleColor; // [reset]
   uint8_t      mColumnRuleStyle;  // [reset]
   uint8_t      mColumnFill;  // [reset] see nsStyleConsts.h
+  uint8_t      mColumnSpan;  // [reset] see nsStyleConsts.h
 
   void SetColumnRuleWidth(nscoord aWidth) {
     mColumnRuleWidth = NS_ROUND_BORDER_TO_PIXELS(aWidth, mTwipsPerPixel);
   }
 
   nscoord GetComputedColumnRuleWidth() const {
     return (IsVisibleBorderStyle(mColumnRuleStyle) ? mColumnRuleWidth : 0);
   }
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -7809,16 +7809,27 @@ for (var prop in gCSSProperties) {
             fieldName in aliasTargetEntry) {
           entry[fieldName] = aliasTargetEntry[fieldName]
         }
       });
     }
   }
 }
 
+if (IsCSSPropertyPrefEnabled("layout.css.column-span.enabled")) {
+  gCSSProperties["column-span"] = {
+    domProp: "columnSpan",
+    inherited: false,
+    type: CSS_TYPE_LONGHAND,
+    initial_values: [ "none" ],
+    other_values: [ "all" ],
+    invalid_values: [ "-1", "0", "auto", "2px" ]
+  };
+}
+
 if (false) {
   // TODO These properties are chrome-only, and are not exposed via CSSOM.
   // We may still want to find a way to test them. See bug 1206999.
   gCSSProperties["-moz-window-shadow"] = {
     //domProp: "MozWindowShadow",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
     initial_values: [ "default" ],
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2677,16 +2677,19 @@ pref("layout.css.font-loading-api.enable
 
 // Should stray control characters be rendered visibly?
 #ifdef RELEASE_OR_BETA
 pref("layout.css.control-characters.visible", false);
 #else
 pref("layout.css.control-characters.visible", true);
 #endif
 
+// Is support for column-span enabled?
+pref("layout.css.column-span.enabled", false);
+
 // pref for which side vertical scrollbars should be on
 // 0 = end-side in UI direction
 // 1 = end-side in document/content direction
 // 2 = right
 // 3 = left
 pref("layout.scrollbar.side", 0);
 
 // pref to stop overlay scrollbars from fading out, for testing purposes