зеркало из https://github.com/mozilla/gecko-dev.git
Bug 696253, patch 4: implement parsing/computation for CSS property 'align-items'. r=dbaron
This commit is contained in:
Родитель
9e077e40c9
Коммит
85e8349a15
|
@ -762,6 +762,9 @@ interface nsIDOMCSS2Properties : nsISupports
|
||||||
layout engine responds to them. In builds with MOZ_FLEXBOX enabled, this
|
layout engine responds to them. In builds with MOZ_FLEXBOX enabled, this
|
||||||
block should be uncommented (and this interface's uuid should be revved).
|
block should be uncommented (and this interface's uuid should be revved).
|
||||||
(This would be #ifdef MOZ_FLEXBOX, if that worked in IDL files.)
|
(This would be #ifdef MOZ_FLEXBOX, if that worked in IDL files.)
|
||||||
|
attribute DOMString MozAlignItems;
|
||||||
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
attribute DOMString MozFlexDirection;
|
attribute DOMString MozFlexDirection;
|
||||||
// raises(DOMException) on setting
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
|
|
|
@ -398,6 +398,16 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
|
||||||
#endif // MOZ_FLEXBOX
|
#endif // MOZ_FLEXBOX
|
||||||
|
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
// See nsStylePosition
|
||||||
|
#define NS_STYLE_ALIGN_ITEMS_FLEX_START 0
|
||||||
|
#define NS_STYLE_ALIGN_ITEMS_FLEX_END 1
|
||||||
|
#define NS_STYLE_ALIGN_ITEMS_CENTER 2
|
||||||
|
#define NS_STYLE_ALIGN_ITEMS_BASELINE 3
|
||||||
|
#define NS_STYLE_ALIGN_ITEMS_STRETCH 4
|
||||||
|
|
||||||
|
// For convenience/clarity (since we use this default value in multiple places)
|
||||||
|
#define NS_STYLE_ALIGN_ITEMS_INITIAL_VALUE NS_STYLE_ALIGN_ITEMS_STRETCH
|
||||||
|
|
||||||
// See nsStylePosition
|
// See nsStylePosition
|
||||||
#define NS_STYLE_FLEX_DIRECTION_ROW 0
|
#define NS_STYLE_FLEX_DIRECTION_ROW 0
|
||||||
#define NS_STYLE_FLEX_DIRECTION_ROW_REVERSE 1
|
#define NS_STYLE_FLEX_DIRECTION_ROW_REVERSE 1
|
||||||
|
|
|
@ -1512,6 +1512,16 @@ CSS_PROP_TABLEBORDER(
|
||||||
CSS_PROP_NO_OFFSET,
|
CSS_PROP_NO_OFFSET,
|
||||||
eStyleAnimType_None)
|
eStyleAnimType_None)
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
CSS_PROP_POSITION(
|
||||||
|
-moz-align-items,
|
||||||
|
align_items,
|
||||||
|
CSS_PROP_DOMPROP_PREFIXED(AlignItems),
|
||||||
|
CSS_PROPERTY_PARSE_VALUE,
|
||||||
|
"",
|
||||||
|
VARIANT_HK,
|
||||||
|
kAlignItemsKTable,
|
||||||
|
offsetof(nsStylePosition, mAlignItems),
|
||||||
|
eStyleAnimType_EnumU8)
|
||||||
CSS_PROP_POSITION(
|
CSS_PROP_POSITION(
|
||||||
-moz-flex-direction,
|
-moz-flex-direction,
|
||||||
flex_direction,
|
flex_direction,
|
||||||
|
|
|
@ -903,6 +903,15 @@ const PRInt32 nsCSSProps::kEmptyCellsKTable[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
const PRInt32 nsCSSProps::kAlignItemsKTable[] = {
|
||||||
|
eCSSKeyword_flex_start, NS_STYLE_ALIGN_ITEMS_FLEX_START,
|
||||||
|
eCSSKeyword_flex_end, NS_STYLE_ALIGN_ITEMS_FLEX_END,
|
||||||
|
eCSSKeyword_center, NS_STYLE_ALIGN_ITEMS_CENTER,
|
||||||
|
eCSSKeyword_baseline, NS_STYLE_ALIGN_ITEMS_BASELINE,
|
||||||
|
eCSSKeyword_stretch, NS_STYLE_ALIGN_ITEMS_STRETCH,
|
||||||
|
eCSSKeyword_UNKNOWN,-1
|
||||||
|
};
|
||||||
|
|
||||||
const PRInt32 nsCSSProps::kFlexDirectionKTable[] = {
|
const PRInt32 nsCSSProps::kFlexDirectionKTable[] = {
|
||||||
eCSSKeyword_row, NS_STYLE_FLEX_DIRECTION_ROW,
|
eCSSKeyword_row, NS_STYLE_FLEX_DIRECTION_ROW,
|
||||||
eCSSKeyword_row_reverse, NS_STYLE_FLEX_DIRECTION_ROW_REVERSE,
|
eCSSKeyword_row_reverse, NS_STYLE_FLEX_DIRECTION_ROW_REVERSE,
|
||||||
|
|
|
@ -351,6 +351,7 @@ public:
|
||||||
static const PRInt32 kElevationKTable[];
|
static const PRInt32 kElevationKTable[];
|
||||||
static const PRInt32 kEmptyCellsKTable[];
|
static const PRInt32 kEmptyCellsKTable[];
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
static const PRInt32 kAlignItemsKTable[];
|
||||||
static const PRInt32 kFlexDirectionKTable[];
|
static const PRInt32 kFlexDirectionKTable[];
|
||||||
static const PRInt32 kJustifyContentKTable[];
|
static const PRInt32 kJustifyContentKTable[];
|
||||||
#endif // MOZ_FLEXBOX
|
#endif // MOZ_FLEXBOX
|
||||||
|
|
|
@ -2925,6 +2925,16 @@ nsComputedDOMStyle::DoGetBorderImageRepeat()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
nsIDOMCSSValue*
|
||||||
|
nsComputedDOMStyle::DoGetAlignItems()
|
||||||
|
{
|
||||||
|
nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
|
||||||
|
val->SetIdent(
|
||||||
|
nsCSSProps::ValueToKeywordEnum(GetStylePosition()->mAlignItems,
|
||||||
|
nsCSSProps::kAlignItemsKTable));
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
nsIDOMCSSValue*
|
nsIDOMCSSValue*
|
||||||
nsComputedDOMStyle::DoGetFlexDirection()
|
nsComputedDOMStyle::DoGetFlexDirection()
|
||||||
{
|
{
|
||||||
|
@ -4639,6 +4649,9 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
|
||||||
* Implementations of -moz- styles *
|
* Implementations of -moz- styles *
|
||||||
\* ******************************* */
|
\* ******************************* */
|
||||||
|
|
||||||
|
#ifdef MOZ_FLEXBOX
|
||||||
|
COMPUTED_STYLE_MAP_ENTRY(align_items, AlignItems),
|
||||||
|
#endif // MOZ_FLEXBOX
|
||||||
COMPUTED_STYLE_MAP_ENTRY(animation_delay, AnimationDelay),
|
COMPUTED_STYLE_MAP_ENTRY(animation_delay, AnimationDelay),
|
||||||
COMPUTED_STYLE_MAP_ENTRY(animation_direction, AnimationDirection),
|
COMPUTED_STYLE_MAP_ENTRY(animation_direction, AnimationDirection),
|
||||||
COMPUTED_STYLE_MAP_ENTRY(animation_duration, AnimationDuration),
|
COMPUTED_STYLE_MAP_ENTRY(animation_duration, AnimationDuration),
|
||||||
|
|
|
@ -359,6 +359,7 @@ private:
|
||||||
|
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
/* CSS Flexbox properties */
|
/* CSS Flexbox properties */
|
||||||
|
nsIDOMCSSValue* DoGetAlignItems();
|
||||||
nsIDOMCSSValue* DoGetFlexDirection();
|
nsIDOMCSSValue* DoGetFlexDirection();
|
||||||
nsIDOMCSSValue* DoGetOrder();
|
nsIDOMCSSValue* DoGetOrder();
|
||||||
nsIDOMCSSValue* DoGetJustifyContent();
|
nsIDOMCSSValue* DoGetJustifyContent();
|
||||||
|
|
|
@ -6425,6 +6425,12 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
||||||
NS_STYLE_BOX_SIZING_CONTENT, 0, 0, 0, 0);
|
NS_STYLE_BOX_SIZING_CONTENT, 0, 0, 0, 0);
|
||||||
|
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
// align-items: enum, inherit, initial
|
||||||
|
SetDiscrete(*aRuleData->ValueForAlignItems(),
|
||||||
|
pos->mAlignItems, canStoreInRuleTree,
|
||||||
|
SETDSC_ENUMERATED, parentPos->mAlignItems,
|
||||||
|
NS_STYLE_ALIGN_ITEMS_INITIAL_VALUE, 0, 0, 0, 0);
|
||||||
|
|
||||||
// flex-direction: enum, inherit, initial
|
// flex-direction: enum, inherit, initial
|
||||||
SetDiscrete(*aRuleData->ValueForFlexDirection(),
|
SetDiscrete(*aRuleData->ValueForFlexDirection(),
|
||||||
pos->mFlexDirection, canStoreInRuleTree,
|
pos->mFlexDirection, canStoreInRuleTree,
|
||||||
|
|
|
@ -1126,6 +1126,7 @@ nsStylePosition::nsStylePosition(void)
|
||||||
mMaxHeight.SetNoneValue();
|
mMaxHeight.SetNoneValue();
|
||||||
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
|
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
mAlignItems = NS_STYLE_ALIGN_ITEMS_INITIAL_VALUE;
|
||||||
mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
|
mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
|
||||||
mJustifyContent = NS_STYLE_JUSTIFY_CONTENT_FLEX_START;
|
mJustifyContent = NS_STYLE_JUSTIFY_CONTENT_FLEX_START;
|
||||||
mOrder = NS_STYLE_ORDER_INITIAL;
|
mOrder = NS_STYLE_ORDER_INITIAL;
|
||||||
|
@ -1166,7 +1167,10 @@ nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) cons
|
||||||
// Properties that apply to flexbox containers:
|
// Properties that apply to flexbox containers:
|
||||||
|
|
||||||
// flex-direction can swap a flexbox between vertical & horizontal.
|
// flex-direction can swap a flexbox between vertical & horizontal.
|
||||||
if (mFlexDirection != aOther.mFlexDirection) {
|
// align-items can change the sizing of a flexbox & the positioning
|
||||||
|
// of its children.
|
||||||
|
if (mAlignItems != aOther.mAlignItems ||
|
||||||
|
mFlexDirection != aOther.mFlexDirection) {
|
||||||
return NS_CombineHint(hint, nsChangeHint_ReflowFrame);
|
return NS_CombineHint(hint, nsChangeHint_ReflowFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1094,6 +1094,7 @@ struct nsStylePosition {
|
||||||
nsStyleCoord mMaxHeight; // [reset] coord, percent, calc, none
|
nsStyleCoord mMaxHeight; // [reset] coord, percent, calc, none
|
||||||
PRUint8 mBoxSizing; // [reset] see nsStyleConsts.h
|
PRUint8 mBoxSizing; // [reset] see nsStyleConsts.h
|
||||||
#ifdef MOZ_FLEXBOX
|
#ifdef MOZ_FLEXBOX
|
||||||
|
PRUint8 mAlignItems; // [reset] see nsStyleConsts.h
|
||||||
PRUint8 mFlexDirection; // [reset] see nsStyleConsts.h
|
PRUint8 mFlexDirection; // [reset] see nsStyleConsts.h
|
||||||
PRUint8 mJustifyContent; // [reset] see nsStyleConsts.h
|
PRUint8 mJustifyContent; // [reset] see nsStyleConsts.h
|
||||||
PRInt32 mOrder; // [reset] integer
|
PRInt32 mOrder; // [reset] integer
|
||||||
|
|
|
@ -738,6 +738,14 @@ var gCSSProperties = {
|
||||||
},
|
},
|
||||||
/* XXXdholbert In builds with MOZ_FLEXBOX enabled, this should be uncommented.
|
/* XXXdholbert In builds with MOZ_FLEXBOX enabled, this should be uncommented.
|
||||||
(This would be #ifdef MOZ_FLEXBOX, if that worked in JS files.)
|
(This would be #ifdef MOZ_FLEXBOX, if that worked in JS files.)
|
||||||
|
"-moz-align-items": {
|
||||||
|
domProp: "MozAlignItems",
|
||||||
|
inherited: false,
|
||||||
|
type: CSS_TYPE_LONGHAND,
|
||||||
|
initial_values: [ "stretch" ],
|
||||||
|
other_values: [ "flex-start", "flex-end", "center", "baseline" ],
|
||||||
|
invalid_values: [ "space-between", "abc", "30px" ]
|
||||||
|
},
|
||||||
"-moz-flex-direction": {
|
"-moz-flex-direction": {
|
||||||
domProp: "MozFlexDirection",
|
domProp: "MozFlexDirection",
|
||||||
inherited: false,
|
inherited: false,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче