зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1176782 part 1 - [css-align] Implement the 'justify-items' property in the style system. r=SimonSapin
This commit is contained in:
Родитель
c93c98f458
Коммит
cb1d1d16b1
|
@ -334,7 +334,9 @@ CSS_KEY(landscape, landscape)
|
|||
CSS_KEY(large, large)
|
||||
CSS_KEY(larger, larger)
|
||||
CSS_KEY(layout, layout)
|
||||
CSS_KEY(last-baseline, last_baseline)
|
||||
CSS_KEY(left, left)
|
||||
CSS_KEY(legacy, legacy)
|
||||
CSS_KEY(lighten, lighten)
|
||||
CSS_KEY(lighter, lighter)
|
||||
CSS_KEY(line-through, line_through)
|
||||
|
@ -459,6 +461,7 @@ CSS_KEY(ruby-text-container, ruby_text_container)
|
|||
CSS_KEY(running, running)
|
||||
CSS_KEY(s, s)
|
||||
CSS_KEY(s-resize, s_resize)
|
||||
CSS_KEY(safe, safe)
|
||||
CSS_KEY(saturate, saturate)
|
||||
CSS_KEY(saturation, saturation)
|
||||
CSS_KEY(scale, scale)
|
||||
|
@ -478,6 +481,8 @@ CSS_KEY(select-all, select_all)
|
|||
CSS_KEY(select-before, select_before)
|
||||
CSS_KEY(select-menu, select_menu)
|
||||
CSS_KEY(select-same, select_same)
|
||||
CSS_KEY(self-end, self_end)
|
||||
CSS_KEY(self-start, self_start)
|
||||
CSS_KEY(semi-condensed, semi_condensed)
|
||||
CSS_KEY(semi-expanded, semi_expanded)
|
||||
CSS_KEY(separate, separate)
|
||||
|
@ -506,6 +511,7 @@ CSS_KEY(soft-light, soft_light)
|
|||
CSS_KEY(solid, solid)
|
||||
CSS_KEY(space-around, space_around)
|
||||
CSS_KEY(space-between, space_between)
|
||||
CSS_KEY(space-evenly, space_evenly)
|
||||
CSS_KEY(span, span)
|
||||
CSS_KEY(spell-out, spell_out)
|
||||
CSS_KEY(square, square)
|
||||
|
@ -727,7 +733,6 @@ CSS_KEY(bevel, bevel)
|
|||
CSS_KEY(butt, butt)
|
||||
CSS_KEY(central, central)
|
||||
CSS_KEY(crispedges, crispedges)
|
||||
//CSS_KEY(end, end)
|
||||
CSS_KEY(evenodd, evenodd)
|
||||
CSS_KEY(geometricprecision, geometricprecision)
|
||||
CSS_KEY(hanging, hanging)
|
||||
|
|
|
@ -935,6 +935,11 @@ protected:
|
|||
nsCSSProperty aEndPropID);
|
||||
bool ParseGridArea();
|
||||
|
||||
// parsing 'align/justify-items/self' from the css-align spec
|
||||
bool ParseAlignJustifyPosition(nsCSSValue& aResult,
|
||||
const KTableValue aTable[]);
|
||||
bool ParseJustifyItems();
|
||||
|
||||
// for 'clip' and '-moz-image-region'
|
||||
bool ParseRect(nsCSSProperty aPropID);
|
||||
bool ParseColumns();
|
||||
|
@ -9378,6 +9383,71 @@ CSSParserImpl::ParseGridArea()
|
|||
return true;
|
||||
}
|
||||
|
||||
// [ $aTable && <overflow-position>? ] ?
|
||||
// $aTable is for <content-position> or <self-position>
|
||||
bool
|
||||
CSSParserImpl::ParseAlignJustifyPosition(nsCSSValue& aResult,
|
||||
const KTableValue aTable[])
|
||||
{
|
||||
nsCSSValue pos, overflowPos;
|
||||
int32_t value = 0;
|
||||
if (ParseEnum(pos, aTable)) {
|
||||
value = pos.GetIntValue();
|
||||
if (ParseEnum(overflowPos, nsCSSProps::kAlignOverflowPosition)) {
|
||||
value |= overflowPos.GetIntValue();
|
||||
}
|
||||
aResult.SetIntValue(value, eCSSUnit_Enumerated);
|
||||
return true;
|
||||
}
|
||||
if (ParseEnum(overflowPos, nsCSSProps::kAlignOverflowPosition)) {
|
||||
if (ParseEnum(pos, aTable)) {
|
||||
aResult.SetIntValue(pos.GetIntValue() | overflowPos.GetIntValue(),
|
||||
eCSSUnit_Enumerated);
|
||||
return true;
|
||||
}
|
||||
return false; // <overflow-position> must be followed by a value in $table
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// auto | stretch | <baseline-position> |
|
||||
// [ <self-position> && <overflow-position>? ] |
|
||||
// [ legacy && [ left | right | center ] ]
|
||||
bool
|
||||
CSSParserImpl::ParseJustifyItems()
|
||||
{
|
||||
nsCSSValue value;
|
||||
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
|
||||
if (MOZ_UNLIKELY(ParseEnum(value, nsCSSProps::kAlignLegacy))) {
|
||||
nsCSSValue legacy;
|
||||
if (!ParseEnum(legacy, nsCSSProps::kAlignLegacyPosition)) {
|
||||
return false; // leading 'legacy' not followed by 'left' etc is an error
|
||||
}
|
||||
value.SetIntValue(value.GetIntValue() | legacy.GetIntValue(),
|
||||
eCSSUnit_Enumerated);
|
||||
} else {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignAutoStretchBaseline)) {
|
||||
if (!ParseAlignJustifyPosition(value, nsCSSProps::kAlignSelfPosition) ||
|
||||
value.GetUnit() == eCSSUnit_Null) {
|
||||
return false;
|
||||
}
|
||||
// check for a trailing 'legacy' after 'left' etc
|
||||
auto val = value.GetIntValue();
|
||||
if (val == NS_STYLE_JUSTIFY_CENTER ||
|
||||
val == NS_STYLE_JUSTIFY_LEFT ||
|
||||
val == NS_STYLE_JUSTIFY_RIGHT) {
|
||||
nsCSSValue legacy;
|
||||
if (ParseEnum(legacy, nsCSSProps::kAlignLegacy)) {
|
||||
value.SetIntValue(val | legacy.GetIntValue(), eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AppendValue(eCSSProperty_justify_items, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// <color-stop> : <color> [ <percentage> | <length> ]?
|
||||
bool
|
||||
CSSParserImpl::ParseColorStop(nsCSSValueGradient* aGradient)
|
||||
|
@ -10501,6 +10571,8 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID)
|
|||
return ParseGridArea();
|
||||
case eCSSProperty_image_region:
|
||||
return ParseRect(eCSSProperty_image_region);
|
||||
case eCSSProperty_justify_items:
|
||||
return ParseJustifyItems();
|
||||
case eCSSProperty_list_style:
|
||||
return ParseListStyle();
|
||||
case eCSSProperty_margin:
|
||||
|
|
|
@ -1707,6 +1707,16 @@ CSS_PROP_POSITION(
|
|||
kJustifyContentKTable,
|
||||
offsetof(nsStylePosition, mJustifyContent),
|
||||
eStyleAnimType_EnumU8)
|
||||
CSS_PROP_POSITION(
|
||||
justify-items,
|
||||
justify_items,
|
||||
JustifyItems,
|
||||
CSS_PROPERTY_PARSE_FUNCTION,
|
||||
"",
|
||||
0,
|
||||
nullptr,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
CSS_PROP_DISPLAY(
|
||||
float,
|
||||
float,
|
||||
|
|
|
@ -1242,6 +1242,68 @@ const KTableValue nsCSSProps::kEmptyCellsKTable[] = {
|
|||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const KTableValue nsCSSProps::kAlignAllKeywords[] = {
|
||||
eCSSKeyword_auto, NS_STYLE_ALIGN_AUTO,
|
||||
eCSSKeyword_start, NS_STYLE_ALIGN_START,
|
||||
eCSSKeyword_end, NS_STYLE_ALIGN_END,
|
||||
eCSSKeyword_flex_start, NS_STYLE_ALIGN_FLEX_START,
|
||||
eCSSKeyword_flex_end, NS_STYLE_ALIGN_FLEX_END,
|
||||
eCSSKeyword_center, NS_STYLE_ALIGN_CENTER,
|
||||
eCSSKeyword_left, NS_STYLE_ALIGN_LEFT,
|
||||
eCSSKeyword_right, NS_STYLE_ALIGN_RIGHT,
|
||||
eCSSKeyword_baseline, NS_STYLE_ALIGN_BASELINE,
|
||||
eCSSKeyword_last_baseline, NS_STYLE_ALIGN_LAST_BASELINE,
|
||||
eCSSKeyword_stretch, NS_STYLE_ALIGN_STRETCH,
|
||||
eCSSKeyword_self_start, NS_STYLE_ALIGN_SELF_START,
|
||||
eCSSKeyword_self_end, NS_STYLE_ALIGN_SELF_END,
|
||||
eCSSKeyword_space_between, NS_STYLE_ALIGN_SPACE_BETWEEN,
|
||||
eCSSKeyword_space_around, NS_STYLE_ALIGN_SPACE_AROUND,
|
||||
eCSSKeyword_space_evenly, NS_STYLE_ALIGN_SPACE_EVENLY,
|
||||
eCSSKeyword_legacy, NS_STYLE_ALIGN_LEGACY,
|
||||
eCSSKeyword_safe, NS_STYLE_ALIGN_SAFE,
|
||||
eCSSKeyword_true, NS_STYLE_ALIGN_TRUE,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const KTableValue nsCSSProps::kAlignOverflowPosition[] = {
|
||||
eCSSKeyword_true, NS_STYLE_ALIGN_TRUE,
|
||||
eCSSKeyword_safe, NS_STYLE_ALIGN_SAFE,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const KTableValue nsCSSProps::kAlignSelfPosition[] = {
|
||||
eCSSKeyword_start, NS_STYLE_ALIGN_START,
|
||||
eCSSKeyword_end, NS_STYLE_ALIGN_END,
|
||||
eCSSKeyword_flex_start, NS_STYLE_ALIGN_FLEX_START,
|
||||
eCSSKeyword_flex_end, NS_STYLE_ALIGN_FLEX_END,
|
||||
eCSSKeyword_center, NS_STYLE_ALIGN_CENTER,
|
||||
eCSSKeyword_left, NS_STYLE_ALIGN_LEFT,
|
||||
eCSSKeyword_right, NS_STYLE_ALIGN_RIGHT,
|
||||
eCSSKeyword_self_start, NS_STYLE_ALIGN_SELF_START,
|
||||
eCSSKeyword_self_end, NS_STYLE_ALIGN_SELF_END,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const KTableValue nsCSSProps::kAlignLegacy[] = {
|
||||
eCSSKeyword_legacy, NS_STYLE_ALIGN_LEGACY,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const KTableValue nsCSSProps::kAlignLegacyPosition[] = {
|
||||
eCSSKeyword_center, NS_STYLE_ALIGN_CENTER,
|
||||
eCSSKeyword_left, NS_STYLE_ALIGN_LEFT,
|
||||
eCSSKeyword_right, NS_STYLE_ALIGN_RIGHT,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const KTableValue nsCSSProps::kAlignAutoStretchBaseline[] = {
|
||||
eCSSKeyword_auto, NS_STYLE_ALIGN_AUTO,
|
||||
eCSSKeyword_stretch, NS_STYLE_ALIGN_STRETCH,
|
||||
eCSSKeyword_baseline, NS_STYLE_ALIGN_BASELINE,
|
||||
eCSSKeyword_last_baseline, NS_STYLE_ALIGN_LAST_BASELINE,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const KTableValue nsCSSProps::kAlignContentKTable[] = {
|
||||
eCSSKeyword_flex_start, NS_STYLE_ALIGN_CONTENT_FLEX_START,
|
||||
eCSSKeyword_flex_end, NS_STYLE_ALIGN_CONTENT_FLEX_END,
|
||||
|
|
|
@ -688,12 +688,20 @@ public:
|
|||
static KTableValue kDisplayKTable[];
|
||||
static const KTableValue kElevationKTable[];
|
||||
static const KTableValue kEmptyCellsKTable[];
|
||||
// -- tables for the align-/justify-content/items/self properties --
|
||||
static const KTableValue kAlignAllKeywords[];
|
||||
static const KTableValue kAlignOverflowPosition[]; // <overflow-position>
|
||||
static const KTableValue kAlignSelfPosition[]; // <self-position>
|
||||
static const KTableValue kAlignLegacy[]; // 'legacy'
|
||||
static const KTableValue kAlignLegacyPosition[]; // 'left/right/center'
|
||||
static const KTableValue kAlignAutoStretchBaseline[]; // 'auto/stretch/baseline/last-baseline'
|
||||
static const KTableValue kAlignContentKTable[];
|
||||
static const KTableValue kAlignItemsKTable[];
|
||||
static const KTableValue kAlignSelfKTable[];
|
||||
static const KTableValue kJustifyContentKTable[];
|
||||
// ------------------------------------------------------------------
|
||||
static const KTableValue kFlexDirectionKTable[];
|
||||
static const KTableValue kFlexWrapKTable[];
|
||||
static const KTableValue kJustifyContentKTable[];
|
||||
static const KTableValue kFloatKTable[];
|
||||
static const KTableValue kFloatEdgeKTable[];
|
||||
static const KTableValue kFontKTable[];
|
||||
|
|
|
@ -1009,6 +1009,28 @@ nsCSSValue::AppendInsetToString(nsCSSProperty aProperty, nsAString& aResult,
|
|||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsCSSValue::AppendAlignJustifyValueToString(int32_t aValue, nsAString& aResult)
|
||||
{
|
||||
auto legacy = aValue & NS_STYLE_ALIGN_LEGACY;
|
||||
if (legacy) {
|
||||
aValue &= ~legacy;
|
||||
aResult.AppendLiteral("legacy ");
|
||||
}
|
||||
auto overflowPos = aValue & (NS_STYLE_ALIGN_SAFE | NS_STYLE_ALIGN_TRUE);
|
||||
aValue &= ~overflowPos;
|
||||
MOZ_ASSERT(!(aValue & NS_STYLE_ALIGN_FLAG_BITS),
|
||||
"unknown bits in align/justify value");
|
||||
const auto& kwtable(nsCSSProps::kAlignAllKeywords);
|
||||
AppendASCIItoUTF16(nsCSSProps::ValueToKeyword(aValue, kwtable), aResult);
|
||||
if (MOZ_UNLIKELY(overflowPos != 0)) {
|
||||
MOZ_ASSERT(legacy == 0, "'legacy' together with <overflow-position>");
|
||||
aResult.Append(' ');
|
||||
AppendASCIItoUTF16(nsCSSProps::ValueToKeyword(overflowPos, kwtable),
|
||||
aResult);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
||||
Serialization aSerialization) const
|
||||
|
@ -1295,6 +1317,10 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult,
|
|||
aResult);
|
||||
break;
|
||||
|
||||
case eCSSProperty_justify_items:
|
||||
AppendAlignJustifyValueToString(intValue, aResult);
|
||||
break;
|
||||
|
||||
default:
|
||||
const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, intValue);
|
||||
AppendASCIItoUTF16(name, aResult);
|
||||
|
|
|
@ -726,6 +726,9 @@ public:
|
|||
const nsCSSValue* aValues[],
|
||||
nsAString& aResult,
|
||||
Serialization aValueSerialization);
|
||||
static void
|
||||
AppendAlignJustifyValueToString(int32_t aValue, nsAString& aResult);
|
||||
|
||||
private:
|
||||
static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) {
|
||||
return static_cast<char16_t*>(aBuffer->Data());
|
||||
|
|
|
@ -3981,6 +3981,18 @@ nsComputedDOMStyle::DoGetJustifyContent()
|
|||
return val;
|
||||
}
|
||||
|
||||
CSSValue*
|
||||
nsComputedDOMStyle::DoGetJustifyItems()
|
||||
{
|
||||
nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
|
||||
nsAutoString str;
|
||||
auto justify = StylePosition()->
|
||||
ComputedJustifyItems(StyleDisplay(), mStyleContext->GetParent());
|
||||
nsCSSValue::AppendAlignJustifyValueToString(justify, str);
|
||||
val->SetString(str);
|
||||
return val;
|
||||
}
|
||||
|
||||
CSSValue*
|
||||
nsComputedDOMStyle::DoGetFloatEdge()
|
||||
{
|
||||
|
|
|
@ -469,16 +469,21 @@ private:
|
|||
mozilla::dom::CSSValue* DoGetAnimationPlayState();
|
||||
|
||||
/* CSS Flexbox properties */
|
||||
mozilla::dom::CSSValue* DoGetAlignContent();
|
||||
mozilla::dom::CSSValue* DoGetAlignItems();
|
||||
mozilla::dom::CSSValue* DoGetAlignSelf();
|
||||
mozilla::dom::CSSValue* DoGetFlexBasis();
|
||||
mozilla::dom::CSSValue* DoGetFlexDirection();
|
||||
mozilla::dom::CSSValue* DoGetFlexGrow();
|
||||
mozilla::dom::CSSValue* DoGetFlexShrink();
|
||||
mozilla::dom::CSSValue* DoGetFlexWrap();
|
||||
|
||||
/* CSS Flexbox/Grid properties */
|
||||
mozilla::dom::CSSValue* DoGetOrder();
|
||||
|
||||
/* CSS Box Alignment properties */
|
||||
mozilla::dom::CSSValue* DoGetAlignContent();
|
||||
mozilla::dom::CSSValue* DoGetAlignItems();
|
||||
mozilla::dom::CSSValue* DoGetAlignSelf();
|
||||
mozilla::dom::CSSValue* DoGetJustifyContent();
|
||||
mozilla::dom::CSSValue* DoGetJustifyItems();
|
||||
|
||||
/* SVG properties */
|
||||
mozilla::dom::CSSValue* DoGetFill();
|
||||
|
|
|
@ -150,6 +150,7 @@ COMPUTED_STYLE_PROP(image_orientation, ImageOrientation)
|
|||
COMPUTED_STYLE_PROP(ime_mode, IMEMode)
|
||||
COMPUTED_STYLE_PROP(isolation, Isolation)
|
||||
COMPUTED_STYLE_PROP(justify_content, JustifyContent)
|
||||
COMPUTED_STYLE_PROP(justify_items, JustifyItems)
|
||||
COMPUTED_STYLE_PROP(left, Left)
|
||||
COMPUTED_STYLE_PROP(letter_spacing, LetterSpacing)
|
||||
COMPUTED_STYLE_PROP(line_height, LineHeight)
|
||||
|
|
|
@ -7859,6 +7859,25 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
|||
0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// justify-items: enum, inherit, initial
|
||||
const auto& justifyItemsValue = *aRuleData->ValueForJustifyItems();
|
||||
if (MOZ_UNLIKELY(justifyItemsValue.GetUnit() == eCSSUnit_Inherit)) {
|
||||
if (MOZ_LIKELY(parentContext)) {
|
||||
pos->mJustifyItems =
|
||||
parentPos->ComputedJustifyItems(parentContext->StyleDisplay(),
|
||||
parentContext);
|
||||
} else {
|
||||
pos->mJustifyItems = NS_STYLE_JUSTIFY_AUTO;
|
||||
}
|
||||
conditions.SetUncacheable();
|
||||
} else {
|
||||
SetDiscrete(justifyItemsValue,
|
||||
pos->mJustifyItems, conditions,
|
||||
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
|
||||
parentPos->mJustifyItems, // unused, we handle 'inherit' above
|
||||
NS_STYLE_JUSTIFY_AUTO, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// flex-basis: auto, length, percent, enum, calc, inherit, initial
|
||||
// (Note: The flags here should match those used for 'width' property above.)
|
||||
SetCoord(*aRuleData->ValueForFlexBasis(), pos->mFlexBasis, parentPos->mFlexBasis,
|
||||
|
|
|
@ -471,6 +471,53 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
|
|||
NS_STYLE_CONTAIN_STYLE | \
|
||||
NS_STYLE_CONTAIN_PAINT)
|
||||
|
||||
// Shared constants for all align/justify properties (nsStylePosition):
|
||||
#define NS_STYLE_ALIGN_AUTO 0
|
||||
#define NS_STYLE_ALIGN_START 1
|
||||
#define NS_STYLE_ALIGN_END 2
|
||||
#define NS_STYLE_ALIGN_FLEX_START 3
|
||||
#define NS_STYLE_ALIGN_FLEX_END 4
|
||||
#define NS_STYLE_ALIGN_CENTER 5
|
||||
#define NS_STYLE_ALIGN_LEFT 6
|
||||
#define NS_STYLE_ALIGN_RIGHT 7
|
||||
#define NS_STYLE_ALIGN_BASELINE 8
|
||||
#define NS_STYLE_ALIGN_LAST_BASELINE 9
|
||||
#define NS_STYLE_ALIGN_STRETCH 10
|
||||
#define NS_STYLE_ALIGN_SELF_START 11
|
||||
#define NS_STYLE_ALIGN_SELF_END 12
|
||||
#define NS_STYLE_ALIGN_SPACE_BETWEEN 13
|
||||
#define NS_STYLE_ALIGN_SPACE_AROUND 14
|
||||
#define NS_STYLE_ALIGN_SPACE_EVENLY 15
|
||||
#define NS_STYLE_ALIGN_LEGACY 0x10 // mutually exclusive w. SAFE & TRUE
|
||||
#define NS_STYLE_ALIGN_SAFE 0x20
|
||||
#define NS_STYLE_ALIGN_TRUE 0x40 // mutually exclusive w. SAFE
|
||||
#define NS_STYLE_ALIGN_FLAG_BITS 0xF0
|
||||
#define NS_STYLE_ALIGN_ALL_BITS 0xFF
|
||||
#define NS_STYLE_ALIGN_ALL_SHIFT 8
|
||||
|
||||
#define NS_STYLE_JUSTIFY_AUTO NS_STYLE_ALIGN_AUTO
|
||||
#define NS_STYLE_JUSTIFY_START NS_STYLE_ALIGN_START
|
||||
#define NS_STYLE_JUSTIFY_END NS_STYLE_ALIGN_END
|
||||
#define NS_STYLE_JUSTIFY_FLEX_START NS_STYLE_ALIGN_FLEX_START
|
||||
#define NS_STYLE_JUSTIFY_FLEX_END NS_STYLE_ALIGN_FLEX_END
|
||||
#define NS_STYLE_JUSTIFY_CENTER NS_STYLE_ALIGN_CENTER
|
||||
#define NS_STYLE_JUSTIFY_LEFT NS_STYLE_ALIGN_LEFT
|
||||
#define NS_STYLE_JUSTIFY_RIGHT NS_STYLE_ALIGN_RIGHT
|
||||
#define NS_STYLE_JUSTIFY_BASELINE NS_STYLE_ALIGN_BASELINE
|
||||
#define NS_STYLE_JUSTIFY_LAST_BASELINE NS_STYLE_ALIGN_LAST_BASELINE
|
||||
#define NS_STYLE_JUSTIFY_STRETCH NS_STYLE_ALIGN_STRETCH
|
||||
#define NS_STYLE_JUSTIFY_SELF_START NS_STYLE_ALIGN_SELF_START
|
||||
#define NS_STYLE_JUSTIFY_SELF_END NS_STYLE_ALIGN_SELF_END
|
||||
#define NS_STYLE_JUSTIFY_SPACE_BETWEEN NS_STYLE_ALIGN_SPACE_BETWEEN
|
||||
#define NS_STYLE_JUSTIFY_SPACE_AROUND NS_STYLE_ALIGN_SPACE_AROUND
|
||||
#define NS_STYLE_JUSTIFY_SPACE_EVENLY NS_STYLE_ALIGN_SPACE_EVENLY
|
||||
#define NS_STYLE_JUSTIFY_LEGACY NS_STYLE_ALIGN_LEGACY
|
||||
#define NS_STYLE_JUSTIFY_SAFE NS_STYLE_ALIGN_SAFE
|
||||
#define NS_STYLE_JUSTIFY_TRUE NS_STYLE_ALIGN_TRUE
|
||||
#define NS_STYLE_JUSTIFY_FLAG_BITS NS_STYLE_ALIGN_FLAG_BITS
|
||||
#define NS_STYLE_JUSTIFY_ALL_BITS NS_STYLE_ALIGN_ALL_BITS
|
||||
#define NS_STYLE_JUSTIFY_ALL_SHIFT NS_STYLE_ALIGN_ALL_SHIFT
|
||||
|
||||
// See nsStylePosition
|
||||
#define NS_STYLE_ALIGN_CONTENT_FLEX_START 0
|
||||
#define NS_STYLE_ALIGN_CONTENT_FLEX_END 1
|
||||
|
|
|
@ -1434,6 +1434,7 @@ nsStylePosition::nsStylePosition(void)
|
|||
mAlignContent = NS_STYLE_ALIGN_CONTENT_STRETCH;
|
||||
mAlignItems = NS_STYLE_ALIGN_ITEMS_INITIAL_VALUE;
|
||||
mAlignSelf = NS_STYLE_ALIGN_SELF_AUTO;
|
||||
mJustifyItems = NS_STYLE_JUSTIFY_AUTO;
|
||||
mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
|
||||
mFlexWrap = NS_STYLE_FLEX_WRAP_NOWRAP;
|
||||
mJustifyContent = NS_STYLE_JUSTIFY_CONTENT_FLEX_START;
|
||||
|
@ -1473,6 +1474,7 @@ nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
|
|||
, mAlignContent(aSource.mAlignContent)
|
||||
, mAlignItems(aSource.mAlignItems)
|
||||
, mAlignSelf(aSource.mAlignSelf)
|
||||
, mJustifyItems(aSource.mJustifyItems)
|
||||
, mFlexDirection(aSource.mFlexDirection)
|
||||
, mFlexWrap(aSource.mFlexWrap)
|
||||
, mJustifyContent(aSource.mJustifyContent)
|
||||
|
@ -1585,9 +1587,10 @@ nsStylePosition::CalcDifference(const nsStylePosition& aOther,
|
|||
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) {
|
||||
// Changing 'justify-content/items' might affect the positioning,
|
||||
// but it won't affect any sizing.
|
||||
if (mJustifyContent != aOther.mJustifyContent ||
|
||||
mJustifyItems != aOther.mJustifyItems) {
|
||||
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
||||
}
|
||||
|
||||
|
@ -1669,6 +1672,25 @@ nsStylePosition::WidthCoordDependsOnContainer(const nsStyleCoord &aCoord)
|
|||
aCoord.GetIntValue() == NS_STYLE_WIDTH_AVAILABLE));
|
||||
}
|
||||
|
||||
uint8_t
|
||||
nsStylePosition::ComputedJustifyItems(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const
|
||||
{
|
||||
if (mJustifyItems != NS_STYLE_JUSTIFY_AUTO) {
|
||||
return mJustifyItems;
|
||||
}
|
||||
if (MOZ_LIKELY(aParent)) {
|
||||
auto inheritedJustifyItems =
|
||||
aParent->StylePosition()->ComputedJustifyItems(aParent->StyleDisplay(),
|
||||
aParent->GetParent());
|
||||
if (inheritedJustifyItems & NS_STYLE_JUSTIFY_LEGACY) {
|
||||
return inheritedJustifyItems;
|
||||
}
|
||||
}
|
||||
return aDisplay->IsFlexOrGridDisplayType() ? NS_STYLE_JUSTIFY_STRETCH
|
||||
: NS_STYLE_JUSTIFY_START;
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// nsStyleTable
|
||||
//
|
||||
|
|
|
@ -1396,6 +1396,13 @@ struct nsStylePosition {
|
|||
// different scope, since we're now using it in multiple style structs.
|
||||
typedef nsStyleBackground::Position Position;
|
||||
|
||||
/**
|
||||
* Return the computed value for 'justify-items' given our 'display' value in
|
||||
* aDisplay and the parent StyleContext aParent (or null for the root).
|
||||
*/
|
||||
uint8_t ComputedJustifyItems(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const;
|
||||
|
||||
Position mObjectPosition; // [reset]
|
||||
nsStyleSides mOffset; // [reset] coord, percent, calc, auto
|
||||
nsStyleCoord mWidth; // [reset] coord, percent, enum, calc, auto
|
||||
|
@ -1414,6 +1421,10 @@ struct nsStylePosition {
|
|||
uint8_t mAlignContent; // [reset] see nsStyleConsts.h
|
||||
uint8_t mAlignItems; // [reset] see nsStyleConsts.h
|
||||
uint8_t mAlignSelf; // [reset] see nsStyleConsts.h
|
||||
private:
|
||||
friend class nsRuleNode;
|
||||
uint8_t mJustifyItems; // [reset] see nsStyleConsts.h
|
||||
public:
|
||||
uint8_t mFlexDirection; // [reset] see nsStyleConsts.h
|
||||
uint8_t mFlexWrap; // [reset] see nsStyleConsts.h
|
||||
uint8_t mJustifyContent; // [reset] see nsStyleConsts.h
|
||||
|
|
|
@ -4071,6 +4071,21 @@ var gCSSProperties = {
|
|||
other_values: [ "flex-start", "flex-end", "center", "baseline" ],
|
||||
invalid_values: [ "space-between", "abc", "30px" ]
|
||||
},
|
||||
"justify-items": {
|
||||
domProp: "justifyItems",
|
||||
inherited: false,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "auto", "start" ],
|
||||
other_values: [ "end", "flex-start", "flex-end", "self-start", "self-end",
|
||||
"center", "left", "right", "baseline", "stretch",
|
||||
"legacy left", "right legacy", "legacy center",
|
||||
"true right", "left true", "safe right", "center safe" ],
|
||||
invalid_values: [ "space-between", "abc", "30px", "legacy", "legacy start",
|
||||
"end legacy", "legacy baseline", "legacy legacy", "true",
|
||||
"safe legacy left", "legacy left safe", "legacy safe left",
|
||||
"safe left legacy", "legacy left legacy", "baseline true",
|
||||
"safe true", "safe left true", "safe stretch" ]
|
||||
},
|
||||
"flex": {
|
||||
domProp: "flex",
|
||||
inherited: false,
|
||||
|
|
Загрузка…
Ссылка в новой задаче