From c2691dbe6c3c68b8649df2a5f85a18fa85c61ed3 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Thu, 17 Apr 2014 12:11:07 +0000 Subject: [PATCH] Bug 613659 - Implement box-decoration-break in the style system. r=cam --- layout/style/nsCSSKeywordList.h | 2 ++ layout/style/nsCSSPropList.h | 10 ++++++++++ layout/style/nsCSSProps.cpp | 6 ++++++ layout/style/nsCSSProps.h | 1 + layout/style/nsComputedDOMStyle.cpp | 10 ++++++++++ layout/style/nsComputedDOMStyle.h | 1 + layout/style/nsRuleNode.cpp | 7 +++++++ layout/style/nsStyleConsts.h | 4 ++++ layout/style/nsStyleStruct.cpp | 5 ++++- layout/style/nsStyleStruct.h | 1 + layout/style/test/property_database.js | 11 +++++++++++ modules/libpref/src/init/all.js | 3 +++ 12 files changed, 60 insertions(+), 1 deletion(-) diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 606023d9b5ae..4f65808a84e7 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -208,6 +208,7 @@ CSS_KEY(circle, circle) CSS_KEY(cjk-decimal, cjk_decimal) CSS_KEY(cjk-ideographic, cjk_ideographic) CSS_KEY(clip, clip) +CSS_KEY(clone, clone) CSS_KEY(close-quote, close_quote) CSS_KEY(closest-corner, closest_corner) CSS_KEY(closest-side, closest_side) @@ -496,6 +497,7 @@ CSS_KEY(skew, skew) CSS_KEY(skewx, skewx) CSS_KEY(skewy, skewy) CSS_KEY(slashed-zero, slashed_zero) +CSS_KEY(slice, slice) CSS_KEY(small, small) CSS_KEY(small-caps, small_caps) CSS_KEY(small-caption, small_caption) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index b78ac87fdb61..c8f0fd00592c 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -1365,6 +1365,16 @@ CSS_PROP_POSITION( nullptr, offsetof(nsStylePosition, mOffset), eStyleAnimType_Sides_Bottom) +CSS_PROP_BORDER( + box-decoration-break, + box_decoration_break, + BoxDecorationBreak, + CSS_PROPERTY_PARSE_VALUE, + "layout.css.box-decoration-break.enabled", + VARIANT_HK, + kBoxDecorationBreakKTable, + CSS_PROP_NO_OFFSET, + eStyleAnimType_None) CSS_PROP_BORDER( box-shadow, box_shadow, diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 886407141b64..4e0c7a01cc3e 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -796,6 +796,12 @@ const KTableValue nsCSSProps::kBoxPropSourceKTable[] = { eCSSKeyword_UNKNOWN,-1 }; +const KTableValue nsCSSProps::kBoxDecorationBreakKTable[] = { + eCSSKeyword_slice, NS_STYLE_BOX_DECORATION_BREAK_SLICE, + eCSSKeyword_clone, NS_STYLE_BOX_DECORATION_BREAK_CLONE, + eCSSKeyword_UNKNOWN,-1 +}; + const KTableValue nsCSSProps::kBoxShadowTypeKTable[] = { eCSSKeyword_inset, NS_STYLE_BOX_SHADOW_INSET, eCSSKeyword_UNKNOWN,-1 diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 84d90baa03de..fde719e5dd42 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -520,6 +520,7 @@ public: static const KTableValue kBorderStyleKTable[]; static const KTableValue kBorderWidthKTable[]; static const KTableValue kBoxAlignKTable[]; + static const KTableValue kBoxDecorationBreakKTable[]; static const KTableValue kBoxDirectionKTable[]; static const KTableValue kBoxOrientKTable[]; static const KTableValue kBoxPackKTable[]; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index dcf90381c5e0..e9a3f31772d4 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -2980,6 +2980,16 @@ nsComputedDOMStyle::GetCSSShadowArray(nsCSSShadowArray* aArray, return valueList; } +CSSValue* +nsComputedDOMStyle::DoGetBoxDecorationBreak() +{ + nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue; + val->SetIdent( + nsCSSProps::ValueToKeywordEnum(StyleBorder()->mBoxDecorationBreak, + nsCSSProps::kBoxDecorationBreakKTable)); + return val; +} + CSSValue* nsComputedDOMStyle::DoGetBoxShadow() { diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index f4a3a8de174f..45e0b841ae55 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -222,6 +222,7 @@ private: /* Box properties */ mozilla::dom::CSSValue* DoGetBoxAlign(); + mozilla::dom::CSSValue* DoGetBoxDecorationBreak(); mozilla::dom::CSSValue* DoGetBoxDirection(); mozilla::dom::CSSValue* DoGetBoxFlex(); mozilla::dom::CSSValue* DoGetBoxOrdinalGroup(); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 9f1e295ffc6d..e1c56f868460 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -6445,6 +6445,13 @@ nsRuleNode::ComputeBorderData(void* aStartStruct, { COMPUTE_START_RESET(Border, (mPresContext), border, parentBorder) + // box-decoration-break: enum, inherit, initial + SetDiscrete(*aRuleData->ValueForBoxDecorationBreak(), + border->mBoxDecorationBreak, canStoreInRuleTree, + SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL, + parentBorder->mBoxDecorationBreak, + NS_STYLE_BOX_DECORATION_BREAK_SLICE, 0, 0, 0, 0); + // box-shadow: none, list, inherit, initial const nsCSSValue* boxShadowValue = aRuleData->ValueForBoxShadow(); switch (boxShadowValue->GetUnit()) { diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index e2de9998afea..1b1d7774fa08 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -117,6 +117,10 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) { #define NS_STYLE_BOX_PACK_END 2 #define NS_STYLE_BOX_PACK_JUSTIFY 3 +// box-decoration-break +#define NS_STYLE_BOX_DECORATION_BREAK_SLICE 0 +#define NS_STYLE_BOX_DECORATION_BREAK_CLONE 1 + // box-direction #define NS_STYLE_BOX_DIRECTION_NORMAL 0 #define NS_STYLE_BOX_DIRECTION_REVERSE 1 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 12592d5472a6..14d59f4ebb7b 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -388,6 +388,7 @@ nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext) mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH), mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH), mFloatEdge(NS_STYLE_FLOAT_EDGE_CONTENT), + mBoxDecorationBreak(NS_STYLE_BOX_DECORATION_BREAK_SLICE), mComputedBorder(0, 0, 0, 0) { MOZ_COUNT_CTOR(nsStyleBorder); @@ -439,6 +440,7 @@ nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc) mBorderImageRepeatH(aSrc.mBorderImageRepeatH), mBorderImageRepeatV(aSrc.mBorderImageRepeatV), mFloatEdge(aSrc.mFloatEdge), + mBoxDecorationBreak(aSrc.mBoxDecorationBreak), mComputedBorder(aSrc.mComputedBorder), mBorder(aSrc.mBorder), mTwipsPerPixel(aSrc.mTwipsPerPixel) @@ -528,7 +530,8 @@ nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const GetComputedBorder() != aOther.GetComputedBorder() || mFloatEdge != aOther.mFloatEdge || mBorderImageOutset != aOther.mBorderImageOutset || - (shadowDifference & nsChangeHint_NeedReflow)) + (shadowDifference & nsChangeHint_NeedReflow) || + mBoxDecorationBreak != aOther.mBoxDecorationBreak) return NS_STYLE_HINT_REFLOW; NS_FOR_CSS_SIDES(ix) { diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index df7287e69de8..05bc1438c39f 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -986,6 +986,7 @@ public: uint8_t mBorderImageRepeatH; // [reset] see nsStyleConsts.h uint8_t mBorderImageRepeatV; // [reset] uint8_t mFloatEdge; // [reset] + uint8_t mBoxDecorationBreak; // [reset] see nsStyleConsts.h protected: // mComputedBorder holds the CSS2.1 computed border-width values. diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index b5ba594a87f1..a68273b39056 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -5387,6 +5387,17 @@ if (SpecialPowers.getBoolPref("layout.css.overflow-clip-box.enabled")) { }; } +if (SpecialPowers.getBoolPref("layout.css.box-decoration-break.enabled")) { + gCSSProperties["box-decoration-break"] = { + domProp: "boxDecorationBreak", + inherited: false, + type: CSS_TYPE_LONGHAND, + initial_values: [ "slice" ], + other_values: [ "clone" ], + invalid_values: [ "auto", "none", "1px" ] + }; +} + if (SpecialPowers.getBoolPref("layout.css.unset-value.enabled")) { gCSSProperties["animation-direction"].invalid_values.push("normal, unset"); gCSSProperties["animation-name"].invalid_values.push("bounce, unset", "unset, bounce"); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 026e3f222efc..af6a472d819c 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -1900,6 +1900,9 @@ pref("layout.css.variables.enabled", true); // Is support for CSS overflow-clip-box enabled for non-UA sheets? pref("layout.css.overflow-clip-box.enabled", false); +// Is support for CSS box-decoration-break enabled? +pref("layout.css.box-decoration-break.enabled", false); + // pref for which side vertical scrollbars should be on // 0 = end-side in UI direction // 1 = end-side in document/content direction