Bug 702508 part 2: Support parsing/computing the CSS property "align-content". r=dbaron

This commit is contained in:
Daniel Holbert 2013-12-05 10:57:50 -08:00
parent c58200db33
commit 951d9cad0d
11 changed files with 78 additions and 0 deletions

View File

@ -1598,6 +1598,16 @@ CSS_PROP_TABLEBORDER(
kEmptyCellsKTable,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
CSS_PROP_POSITION(
align-content,
align_content,
AlignContent,
CSS_PROPERTY_PARSE_VALUE,
"",
VARIANT_HK,
kAlignContentKTable,
offsetof(nsStylePosition, mAlignContent),
eStyleAnimType_EnumU8)
CSS_PROP_POSITION(
align-items,
align_items,

View File

@ -973,6 +973,16 @@ const int32_t nsCSSProps::kEmptyCellsKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
const int32_t nsCSSProps::kAlignContentKTable[] = {
eCSSKeyword_flex_start, NS_STYLE_ALIGN_CONTENT_FLEX_START,
eCSSKeyword_flex_end, NS_STYLE_ALIGN_CONTENT_FLEX_END,
eCSSKeyword_center, NS_STYLE_ALIGN_CONTENT_CENTER,
eCSSKeyword_space_between, NS_STYLE_ALIGN_CONTENT_SPACE_BETWEEN,
eCSSKeyword_space_around, NS_STYLE_ALIGN_CONTENT_SPACE_AROUND,
eCSSKeyword_stretch, NS_STYLE_ALIGN_CONTENT_STRETCH,
eCSSKeyword_UNKNOWN,-1
};
const int32_t nsCSSProps::kAlignItemsKTable[] = {
eCSSKeyword_flex_start, NS_STYLE_ALIGN_ITEMS_FLEX_START,
eCSSKeyword_flex_end, NS_STYLE_ALIGN_ITEMS_FLEX_END,

View File

@ -479,6 +479,7 @@ public:
static const int32_t kDisplayKTable[];
static const int32_t kElevationKTable[];
static const int32_t kEmptyCellsKTable[];
static const int32_t kAlignContentKTable[];
static const int32_t kAlignItemsKTable[];
static const int32_t kAlignSelfKTable[];
static const int32_t kFlexDirectionKTable[];

View File

@ -3355,6 +3355,16 @@ nsComputedDOMStyle::DoGetBorderImageRepeat()
return valueList;
}
CSSValue*
nsComputedDOMStyle::DoGetAlignContent()
{
nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(StylePosition()->mAlignContent,
nsCSSProps::kAlignContentKTable));
return val;
}
CSSValue*
nsComputedDOMStyle::DoGetAlignItems()
{

View File

@ -439,6 +439,7 @@ private:
mozilla::dom::CSSValue* DoGetAnimationPlayState();
/* CSS Flexbox properties */
mozilla::dom::CSSValue* DoGetAlignContent();
mozilla::dom::CSSValue* DoGetAlignItems();
mozilla::dom::CSSValue* DoGetAlignSelf();
mozilla::dom::CSSValue* DoGetFlexBasis();

View File

@ -39,6 +39,7 @@
* Implementations of CSS styles *
\* ***************************** */
COMPUTED_STYLE_PROP(align_content, AlignContent)
COMPUTED_STYLE_PROP(align_items, AlignItems)
COMPUTED_STYLE_PROP(align_self, AlignSelf)
//// COMPUTED_STYLE_PROP(animation, Animation)

View File

@ -6958,6 +6958,13 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
parentPos->mBoxSizing,
NS_STYLE_BOX_SIZING_CONTENT, 0, 0, 0, 0);
// align-content: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForAlignContent(),
pos->mAlignContent, canStoreInRuleTree,
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
parentPos->mAlignContent,
NS_STYLE_ALIGN_CONTENT_STRETCH, 0, 0, 0, 0);
// align-items: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForAlignItems(),
pos->mAlignItems, canStoreInRuleTree,

View File

@ -402,6 +402,14 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_DISPLAY_FLEX 29
#define NS_STYLE_DISPLAY_INLINE_FLEX 30
// See nsStylePosition
#define NS_STYLE_ALIGN_CONTENT_FLEX_START 0
#define NS_STYLE_ALIGN_CONTENT_FLEX_END 1
#define NS_STYLE_ALIGN_CONTENT_CENTER 2
#define NS_STYLE_ALIGN_CONTENT_SPACE_BETWEEN 3
#define NS_STYLE_ALIGN_CONTENT_SPACE_AROUND 4
#define NS_STYLE_ALIGN_CONTENT_STRETCH 5
// See nsStylePosition
#define NS_STYLE_ALIGN_ITEMS_FLEX_START 0
#define NS_STYLE_ALIGN_ITEMS_FLEX_END 1

View File

@ -1272,6 +1272,7 @@ nsStylePosition::nsStylePosition(void)
mMaxHeight.SetNoneValue();
mFlexBasis.SetAutoValue();
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
mAlignContent = NS_STYLE_ALIGN_CONTENT_STRETCH;
mAlignItems = NS_STYLE_ALIGN_ITEMS_INITIAL_VALUE;
mAlignSelf = NS_STYLE_ALIGN_SELF_AUTO;
mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
@ -1340,12 +1341,26 @@ nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) cons
return NS_CombineHint(hint, nsChangeHint_AllReflowHints);
}
// Changing justify-content on a flexbox might affect the positioning of its
// children, but it won't affect any sizing.
if (mJustifyContent != aOther.mJustifyContent) {
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
}
// Properties that apply only to multi-line flex containers:
// 'align-content' can change the positioning & sizing of a multi-line flex
// container's children when there's extra space in the cross axis, but it
// shouldn't affect the container's own sizing.
//
// NOTE: If we get here, we know that mFlexWrap == aOther.mFlexWrap
// (otherwise, we would've returned earlier). So it doesn't matter which one
// of those we check to see if we're multi-line.
if (mFlexWrap != NS_STYLE_FLEX_WRAP_NOWRAP &&
mAlignContent != aOther.mAlignContent) {
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
}
if (mHeight != aOther.mHeight ||
mMinHeight != aOther.mMinHeight ||
mMaxHeight != aOther.mMaxHeight) {

View File

@ -1129,6 +1129,7 @@ struct nsStylePosition {
nsStyleCoord mMaxHeight; // [reset] coord, percent, calc, none
nsStyleCoord mFlexBasis; // [reset] coord, percent, enum, calc, auto
uint8_t mBoxSizing; // [reset] see nsStyleConsts.h
uint8_t mAlignContent; // [reset] see nsStyleConsts.h
uint8_t mAlignItems; // [reset] see nsStyleConsts.h
uint8_t mAlignSelf; // [reset] see nsStyleConsts.h
uint8_t mFlexDirection; // [reset] see nsStyleConsts.h

View File

@ -3696,6 +3696,20 @@ var gCSSProperties = {
other_values: [ "non-scaling-stroke" ],
invalid_values: []
},
"align-content": {
domProp: "alignContent",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "stretch" ],
other_values: [
"flex-start",
"flex-end",
"center",
"space-between",
"space-around"
],
invalid_values: [ "abc", "30px", "0", "auto" ]
},
"align-items": {
domProp: "alignItems",
inherited: false,