Bug 1233106 part 1 - [css-align] Update align-/justify-* properties to the current CSS Align spec (adding 'normal' keyword, dropping 'auto' in some cases etc). r=dholbert
The CSSWG minutes for reference: https://lists.w3.org/Archives/Public/www-style/2015Dec/0233.html With subsequent correction for the root node: https://lists.w3.org/Archives/Public/www-style/2016Jan/0015.html
This commit is contained in:
@@ -1571,11 +1571,8 @@ FlexItem::FlexItem(nsHTMLReflowState& aFlexItemReflowState,
|
||||
"out-of-flow frames should not be treated as flex items");
|
||||
|
||||
mAlignSelf = aFlexItemReflowState.mStylePosition->ComputedAlignSelf(
|
||||
aFlexItemReflowState.mStyleDisplay,
|
||||
mFrame->StyleContext()->GetParent());
|
||||
if (MOZ_UNLIKELY(mAlignSelf == NS_STYLE_ALIGN_AUTO)) {
|
||||
// Happens in rare edge cases when 'position' was ignored by the frame
|
||||
// constructor (and the style system computed 'auto' based on 'position').
|
||||
if (MOZ_LIKELY(mAlignSelf == NS_STYLE_ALIGN_NORMAL)) {
|
||||
mAlignSelf = NS_STYLE_ALIGN_STRETCH;
|
||||
}
|
||||
|
||||
@@ -2432,8 +2429,11 @@ MainAxisPositionTracker::
|
||||
mNumPackingSpacesRemaining(0),
|
||||
mJustifyContent(aJustifyContent)
|
||||
{
|
||||
// 'auto' behaves as 'stretch' which behaves as 'flex-start' in the main axis
|
||||
if (mJustifyContent == NS_STYLE_JUSTIFY_AUTO) {
|
||||
// 'normal' behaves as 'stretch', and 'stretch' behaves as 'flex-start',
|
||||
// in the main axis
|
||||
// https://drafts.csswg.org/css-align-3/#propdef-justify-content
|
||||
if (mJustifyContent == NS_STYLE_JUSTIFY_NORMAL ||
|
||||
mJustifyContent == NS_STYLE_JUSTIFY_STRETCH) {
|
||||
mJustifyContent = NS_STYLE_JUSTIFY_FLEX_START;
|
||||
}
|
||||
|
||||
@@ -2607,8 +2607,8 @@ CrossAxisPositionTracker::
|
||||
{
|
||||
MOZ_ASSERT(aFirstLine, "null first line pointer");
|
||||
|
||||
// 'auto' behaves as 'stretch'
|
||||
if (mAlignContent == NS_STYLE_ALIGN_AUTO) {
|
||||
// 'normal' behaves as 'stretch'
|
||||
if (mAlignContent == NS_STYLE_ALIGN_NORMAL) {
|
||||
mAlignContent = NS_STYLE_ALIGN_STRETCH;
|
||||
}
|
||||
|
||||
@@ -3839,8 +3839,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
|
||||
|
||||
// Main-Axis Alignment - Flexbox spec section 9.5
|
||||
// ==============================================
|
||||
auto justifyContent =
|
||||
aReflowState.mStylePosition->ComputedJustifyContent(aReflowState.mStyleDisplay);
|
||||
auto justifyContent = aReflowState.mStylePosition->ComputedJustifyContent();
|
||||
line->PositionItemsInMainAxis(justifyContent,
|
||||
aContentBoxMainSize,
|
||||
aAxisTracker);
|
||||
|
||||
@@ -1287,9 +1287,7 @@ AlignSelf(uint8_t aAlignSelf, const LogicalRect& aCB, const WritingMode aCBWM,
|
||||
if (alignSelf == NS_STYLE_ALIGN_LEFT || alignSelf == NS_STYLE_ALIGN_RIGHT) {
|
||||
alignSelf = NS_STYLE_ALIGN_START;
|
||||
}
|
||||
if (MOZ_UNLIKELY(alignSelf == NS_STYLE_ALIGN_AUTO)) {
|
||||
// Happens in rare edge cases when 'position' was ignored by the frame
|
||||
// constructor (and the style system computed 'auto' based on 'position').
|
||||
if (MOZ_LIKELY(alignSelf == NS_STYLE_ALIGN_NORMAL)) {
|
||||
alignSelf = NS_STYLE_ALIGN_STRETCH;
|
||||
}
|
||||
WritingMode childWM = aRS.GetWritingMode();
|
||||
@@ -1316,9 +1314,7 @@ JustifySelf(uint8_t aJustifySelf, const LogicalRect& aCB, const WritingMode aCBW
|
||||
auto justifySelf = aJustifySelf;
|
||||
bool overflowSafe = justifySelf & NS_STYLE_JUSTIFY_SAFE;
|
||||
justifySelf &= ~NS_STYLE_JUSTIFY_FLAG_BITS;
|
||||
if (MOZ_UNLIKELY(justifySelf == NS_STYLE_ALIGN_AUTO)) {
|
||||
// Happens in rare edge cases when 'position' was ignored by the frame
|
||||
// constructor (and the style system computed 'auto' based on 'position').
|
||||
if (MOZ_LIKELY(justifySelf == NS_STYLE_ALIGN_NORMAL)) {
|
||||
justifySelf = NS_STYLE_ALIGN_STRETCH;
|
||||
}
|
||||
WritingMode childWM = aRS.GetWritingMode();
|
||||
@@ -2915,12 +2911,12 @@ nsGridContainerFrame::Tracks::AlignJustifyContent(
|
||||
auto stylePos = aReflowState.mStylePosition;
|
||||
const auto valueAndFallback = isAlign ?
|
||||
stylePos->ComputedAlignContent() :
|
||||
stylePos->ComputedJustifyContent(aReflowState.mStyleDisplay);
|
||||
stylePos->ComputedJustifyContent();
|
||||
WritingMode wm = aReflowState.GetWritingMode();
|
||||
bool overflowSafe;
|
||||
auto alignment = ::GetAlignJustifyValue(valueAndFallback, wm, isAlign,
|
||||
&overflowSafe);
|
||||
if (alignment == NS_STYLE_ALIGN_AUTO) {
|
||||
if (alignment == NS_STYLE_ALIGN_NORMAL) {
|
||||
alignment = NS_STYLE_ALIGN_START;
|
||||
}
|
||||
|
||||
@@ -3182,12 +3178,10 @@ nsGridContainerFrame::ReflowChildren(GridReflowState& aState,
|
||||
if (isGridItem) {
|
||||
LogicalSize oldSize = childSize->Size(childWM); // from the ReflowChild()
|
||||
LogicalSize newContentSize(childWM);
|
||||
auto align = childRS->mStylePosition->ComputedAlignSelf(
|
||||
childRS->mStyleDisplay, containerSC);
|
||||
auto align = childRS->mStylePosition->ComputedAlignSelf(containerSC);
|
||||
Maybe<LogicalAxis> alignResize =
|
||||
AlignSelf(align, cb, wm, *childRS, oldSize, &newContentSize, &childPos);
|
||||
auto justify = childRS->mStylePosition->ComputedJustifySelf(
|
||||
childRS->mStyleDisplay, containerSC);
|
||||
auto justify = childRS->mStylePosition->ComputedJustifySelf(containerSC);
|
||||
Maybe<LogicalAxis> justifyResize =
|
||||
JustifySelf(justify, cb, wm, *childRS, oldSize, &newContentSize, &childPos);
|
||||
if (alignResize || justifyResize) {
|
||||
|
||||
@@ -2306,11 +2306,10 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
|
||||
// Shrink-wrap grid items that will be aligned (rather than stretched)
|
||||
// in its inline axis.
|
||||
auto inlineAxisAlignment = wm.IsOrthogonalTo(cbwm) ?
|
||||
mStylePosition->ComputedAlignSelf(mStyleDisplay,
|
||||
frame->StyleContext()->GetParent()) :
|
||||
mStylePosition->ComputedJustifySelf(mStyleDisplay,
|
||||
frame->StyleContext()->GetParent());
|
||||
if (inlineAxisAlignment != NS_STYLE_ALIGN_STRETCH ||
|
||||
mStylePosition->ComputedAlignSelf(frame->StyleContext()->GetParent()) :
|
||||
mStylePosition->ComputedJustifySelf(frame->StyleContext()->GetParent());
|
||||
if ((inlineAxisAlignment != NS_STYLE_ALIGN_STRETCH &&
|
||||
inlineAxisAlignment != NS_STYLE_ALIGN_NORMAL) ||
|
||||
mStyleMargin->mMargin.GetIStartUnit(wm) == eStyleUnit_Auto ||
|
||||
mStyleMargin->mMargin.GetIEndUnit(wm) == eStyleUnit_Auto) {
|
||||
computeSizeFlags =
|
||||
|
||||
@@ -985,7 +985,8 @@ protected:
|
||||
bool ParseAlignJustifyPosition(nsCSSValue& aResult,
|
||||
const KTableEntry aTable[]);
|
||||
bool ParseJustifyItems();
|
||||
bool ParseAlignItemsSelfJustifySelf(nsCSSProperty aPropID);
|
||||
bool ParseAlignItems();
|
||||
bool ParseAlignJustifySelf(nsCSSProperty aPropID);
|
||||
// parsing 'align/justify-content' from the css-align spec
|
||||
bool ParseAlignJustifyContent(nsCSSProperty aPropID);
|
||||
|
||||
@@ -9636,7 +9637,7 @@ CSSParserImpl::ParseAlignJustifyPosition(nsCSSValue& aResult,
|
||||
return true;
|
||||
}
|
||||
|
||||
// auto | stretch | <baseline-position> |
|
||||
// auto | normal | stretch | <baseline-position> |
|
||||
// [ <self-position> && <overflow-position>? ] |
|
||||
// [ legacy && [ left | right | center ] ]
|
||||
bool
|
||||
@@ -9652,7 +9653,7 @@ CSSParserImpl::ParseJustifyItems()
|
||||
value.SetIntValue(value.GetIntValue() | legacy.GetIntValue(),
|
||||
eCSSUnit_Enumerated);
|
||||
} else {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignAutoStretchBaseline)) {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignAutoNormalStretchBaseline)) {
|
||||
if (!ParseAlignJustifyPosition(value, nsCSSProps::kAlignSelfPosition) ||
|
||||
value.GetUnit() == eCSSUnit_Null) {
|
||||
return false;
|
||||
@@ -9674,14 +9675,32 @@ CSSParserImpl::ParseJustifyItems()
|
||||
return true;
|
||||
}
|
||||
|
||||
// auto | stretch | <baseline-position> |
|
||||
// normal | stretch | <baseline-position> |
|
||||
// [ <overflow-position>? && <self-position> ]
|
||||
bool
|
||||
CSSParserImpl::ParseAlignItemsSelfJustifySelf(nsCSSProperty aPropID)
|
||||
CSSParserImpl::ParseAlignItems()
|
||||
{
|
||||
nsCSSValue value;
|
||||
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignAutoStretchBaseline)) {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignNormalStretchBaseline)) {
|
||||
if (!ParseAlignJustifyPosition(value, nsCSSProps::kAlignSelfPosition) ||
|
||||
value.GetUnit() == eCSSUnit_Null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
AppendValue(eCSSProperty_align_items, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// auto | normal | stretch | <baseline-position> |
|
||||
// [ <overflow-position>? && <self-position> ]
|
||||
bool
|
||||
CSSParserImpl::ParseAlignJustifySelf(nsCSSProperty aPropID)
|
||||
{
|
||||
nsCSSValue value;
|
||||
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignAutoNormalStretchBaseline)) {
|
||||
if (!ParseAlignJustifyPosition(value, nsCSSProps::kAlignSelfPosition) ||
|
||||
value.GetUnit() == eCSSUnit_Null) {
|
||||
return false;
|
||||
@@ -9692,7 +9711,7 @@ CSSParserImpl::ParseAlignItemsSelfJustifySelf(nsCSSProperty aPropID)
|
||||
return true;
|
||||
}
|
||||
|
||||
// auto | <baseline-position> | [ <content-distribution> ||
|
||||
// normal | <baseline-position> | [ <content-distribution> ||
|
||||
// [ <overflow-position>? && <content-position> ] ]
|
||||
// (the part after the || is called <*-position> below)
|
||||
bool
|
||||
@@ -9700,7 +9719,7 @@ CSSParserImpl::ParseAlignJustifyContent(nsCSSProperty aPropID)
|
||||
{
|
||||
nsCSSValue value;
|
||||
if (!ParseSingleTokenVariant(value, VARIANT_INHERIT, nullptr)) {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignAutoBaseline)) {
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignNormalBaseline)) {
|
||||
nsCSSValue fallbackValue;
|
||||
if (!ParseEnum(value, nsCSSProps::kAlignContentDistribution)) {
|
||||
if (!ParseAlignJustifyPosition(fallbackValue,
|
||||
@@ -9723,7 +9742,8 @@ CSSParserImpl::ParseAlignJustifyContent(nsCSSProperty aPropID)
|
||||
}
|
||||
if (fallbackValue.GetUnit() != eCSSUnit_Null) {
|
||||
auto fallback = fallbackValue.GetIntValue();
|
||||
value.SetIntValue(value.GetIntValue() | (fallback << 8),
|
||||
value.SetIntValue(value.GetIntValue() |
|
||||
(fallback << NS_STYLE_ALIGN_ALL_SHIFT),
|
||||
eCSSUnit_Enumerated);
|
||||
}
|
||||
}
|
||||
@@ -11336,15 +11356,15 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID)
|
||||
case eCSSProperty_align_content:
|
||||
return ParseAlignJustifyContent(aPropID);
|
||||
case eCSSProperty_align_items:
|
||||
return ParseAlignItemsSelfJustifySelf(aPropID);
|
||||
return ParseAlignItems();
|
||||
case eCSSProperty_align_self:
|
||||
return ParseAlignItemsSelfJustifySelf(aPropID);
|
||||
return ParseAlignJustifySelf(aPropID);
|
||||
case eCSSProperty_justify_content:
|
||||
return ParseAlignJustifyContent(aPropID);
|
||||
case eCSSProperty_justify_items:
|
||||
return ParseJustifyItems();
|
||||
case eCSSProperty_justify_self:
|
||||
return ParseAlignItemsSelfJustifySelf(aPropID);
|
||||
return ParseAlignJustifySelf(aPropID);
|
||||
case eCSSProperty_list_style:
|
||||
return ParseListStyle();
|
||||
case eCSSProperty_margin:
|
||||
|
||||
@@ -1248,6 +1248,7 @@ const KTableEntry nsCSSProps::kEmptyCellsKTable[] = {
|
||||
|
||||
const KTableEntry nsCSSProps::kAlignAllKeywords[] = {
|
||||
{ eCSSKeyword_auto, NS_STYLE_ALIGN_AUTO },
|
||||
{ eCSSKeyword_normal, NS_STYLE_ALIGN_NORMAL },
|
||||
{ eCSSKeyword_start, NS_STYLE_ALIGN_START },
|
||||
{ eCSSKeyword_end, NS_STYLE_ALIGN_END },
|
||||
{ eCSSKeyword_flex_start, NS_STYLE_ALIGN_FLEX_START },
|
||||
@@ -1300,16 +1301,25 @@ const KTableEntry nsCSSProps::kAlignLegacyPosition[] = {
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kAlignAutoStretchBaseline[] = {
|
||||
const KTableEntry nsCSSProps::kAlignAutoNormalStretchBaseline[] = {
|
||||
{ eCSSKeyword_auto, NS_STYLE_ALIGN_AUTO },
|
||||
{ eCSSKeyword_normal, NS_STYLE_ALIGN_NORMAL },
|
||||
{ eCSSKeyword_stretch, NS_STYLE_ALIGN_STRETCH },
|
||||
{ eCSSKeyword_baseline, NS_STYLE_ALIGN_BASELINE },
|
||||
{ eCSSKeyword_last_baseline, NS_STYLE_ALIGN_LAST_BASELINE },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kAlignAutoBaseline[] = {
|
||||
{ eCSSKeyword_auto, NS_STYLE_ALIGN_AUTO },
|
||||
const KTableEntry nsCSSProps::kAlignNormalStretchBaseline[] = {
|
||||
{ eCSSKeyword_normal, NS_STYLE_ALIGN_NORMAL },
|
||||
{ eCSSKeyword_stretch, NS_STYLE_ALIGN_STRETCH },
|
||||
{ eCSSKeyword_baseline, NS_STYLE_ALIGN_BASELINE },
|
||||
{ eCSSKeyword_last_baseline, NS_STYLE_ALIGN_LAST_BASELINE },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kAlignNormalBaseline[] = {
|
||||
{ eCSSKeyword_normal, NS_STYLE_ALIGN_NORMAL },
|
||||
{ eCSSKeyword_baseline, NS_STYLE_ALIGN_BASELINE },
|
||||
{ eCSSKeyword_last_baseline, NS_STYLE_ALIGN_LAST_BASELINE },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
|
||||
@@ -727,8 +727,9 @@ public:
|
||||
static const KTableEntry kAlignSelfPosition[]; // <self-position>
|
||||
static const KTableEntry kAlignLegacy[]; // 'legacy'
|
||||
static const KTableEntry kAlignLegacyPosition[]; // 'left/right/center'
|
||||
static const KTableEntry kAlignAutoStretchBaseline[]; // 'auto/stretch/baseline/last-baseline'
|
||||
static const KTableEntry kAlignAutoBaseline[]; // 'auto/baseline/last-baseline'
|
||||
static const KTableEntry kAlignAutoNormalStretchBaseline[]; // 'auto/normal/stretch/baseline/last-baseline'
|
||||
static const KTableEntry kAlignNormalStretchBaseline[]; // 'normal/stretch/baseline/last-baseline'
|
||||
static const KTableEntry kAlignNormalBaseline[]; // 'normal/baseline/last-baseline'
|
||||
static const KTableEntry kAlignContentDistribution[]; // <content-distribution>
|
||||
static const KTableEntry kAlignContentPosition[]; // <content-position>
|
||||
static const KTableEntry kAlignSelfKTable[];
|
||||
|
||||
@@ -1022,10 +1022,11 @@ nsCSSValue::AppendAlignJustifyValueToString(int32_t aValue, nsAString& aResult)
|
||||
MOZ_ASSERT(!(aValue & NS_STYLE_ALIGN_FLAG_BITS),
|
||||
"unknown bits in align/justify value");
|
||||
MOZ_ASSERT((aValue != NS_STYLE_ALIGN_AUTO &&
|
||||
aValue != NS_STYLE_ALIGN_NORMAL &&
|
||||
aValue != NS_STYLE_ALIGN_BASELINE &&
|
||||
aValue != NS_STYLE_ALIGN_LAST_BASELINE) ||
|
||||
(!legacy && !overflowPos),
|
||||
"auto/baseline/last-baseline never have any flags");
|
||||
"auto/normal/baseline/last-baseline never have any flags");
|
||||
MOZ_ASSERT(legacy == 0 || overflowPos == 0,
|
||||
"'legacy' together with <overflow-position>");
|
||||
const auto& kwtable(nsCSSProps::kAlignAllKeywords);
|
||||
|
||||
@@ -4190,7 +4190,7 @@ nsComputedDOMStyle::DoGetAlignItems()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
nsAutoString str;
|
||||
auto align = StylePosition()->ComputedAlignItems(StyleDisplay());
|
||||
auto align = StylePosition()->ComputedAlignItems();
|
||||
nsCSSValue::AppendAlignJustifyValueToString(align, str);
|
||||
val->SetString(str);
|
||||
return val.forget();
|
||||
@@ -4200,8 +4200,7 @@ already_AddRefed<CSSValue>
|
||||
nsComputedDOMStyle::DoGetAlignSelf()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
auto align = StylePosition()->
|
||||
ComputedAlignSelf(StyleDisplay(), mStyleContext->GetParent());
|
||||
auto align = StylePosition()->ComputedAlignSelf(mStyleContext->GetParent());
|
||||
nsAutoString str;
|
||||
nsCSSValue::AppendAlignJustifyValueToString(align, str);
|
||||
val->SetString(str);
|
||||
@@ -4213,7 +4212,7 @@ nsComputedDOMStyle::DoGetJustifyContent()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
nsAutoString str;
|
||||
auto justify = StylePosition()->ComputedJustifyContent(StyleDisplay());
|
||||
auto justify = StylePosition()->ComputedJustifyContent();
|
||||
nsCSSValue::AppendAlignJustifyValueToString(justify & NS_STYLE_JUSTIFY_ALL_BITS, str);
|
||||
auto fallback = justify >> NS_STYLE_JUSTIFY_ALL_SHIFT;
|
||||
if (fallback) {
|
||||
@@ -4232,8 +4231,8 @@ nsComputedDOMStyle::DoGetJustifyItems()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
nsAutoString str;
|
||||
auto justify = StylePosition()->
|
||||
ComputedJustifyItems(StyleDisplay(), mStyleContext->GetParent());
|
||||
auto justify =
|
||||
StylePosition()->ComputedJustifyItems(mStyleContext->GetParent());
|
||||
nsCSSValue::AppendAlignJustifyValueToString(justify, str);
|
||||
val->SetString(str);
|
||||
return val.forget();
|
||||
@@ -4244,8 +4243,8 @@ nsComputedDOMStyle::DoGetJustifySelf()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
nsAutoString str;
|
||||
auto justify = StylePosition()->
|
||||
ComputedJustifySelf(StyleDisplay(), mStyleContext->GetParent());
|
||||
auto justify =
|
||||
StylePosition()->ComputedJustifySelf(mStyleContext->GetParent());
|
||||
nsCSSValue::AppendAlignJustifyValueToString(justify, str);
|
||||
val->SetString(str);
|
||||
return val.forget();
|
||||
|
||||
@@ -8090,25 +8090,14 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
||||
pos->mAlignContent, conditions,
|
||||
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
|
||||
parentPos->mAlignContent,
|
||||
NS_STYLE_ALIGN_AUTO, 0, 0, 0, 0);
|
||||
NS_STYLE_ALIGN_NORMAL, 0, 0, 0, 0);
|
||||
|
||||
// align-items: enum, inherit, initial
|
||||
const auto& alignItemsValue = *aRuleData->ValueForAlignItems();
|
||||
if (MOZ_UNLIKELY(alignItemsValue.GetUnit() == eCSSUnit_Inherit)) {
|
||||
if (MOZ_LIKELY(parentContext)) {
|
||||
pos->mAlignItems =
|
||||
parentPos->ComputedAlignItems(parentContext->StyleDisplay());
|
||||
} else {
|
||||
pos->mAlignItems = NS_STYLE_ALIGN_AUTO;
|
||||
}
|
||||
conditions.SetUncacheable();
|
||||
} else {
|
||||
SetDiscrete(alignItemsValue,
|
||||
pos->mAlignItems, conditions,
|
||||
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
|
||||
parentPos->mAlignItems, // unused, we handle 'inherit' above
|
||||
NS_STYLE_ALIGN_AUTO, 0, 0, 0, 0);
|
||||
}
|
||||
SetDiscrete(*aRuleData->ValueForAlignItems(),
|
||||
pos->mAlignItems, conditions,
|
||||
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
|
||||
parentPos->mAlignItems,
|
||||
NS_STYLE_ALIGN_NORMAL, 0, 0, 0, 0);
|
||||
|
||||
// align-self: enum, inherit, initial
|
||||
const auto& alignSelfValue = *aRuleData->ValueForAlignSelf();
|
||||
@@ -8118,11 +8107,9 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
||||
if (MOZ_LIKELY(grandparentContext)) {
|
||||
parentContext->AddStyleBit(NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE);
|
||||
}
|
||||
pos->mAlignSelf =
|
||||
parentPos->ComputedAlignSelf(parentContext->StyleDisplay(),
|
||||
grandparentContext);
|
||||
pos->mAlignSelf = parentPos->ComputedAlignSelf(grandparentContext);
|
||||
} else {
|
||||
pos->mAlignSelf = NS_STYLE_ALIGN_START;
|
||||
pos->mAlignSelf = NS_STYLE_ALIGN_NORMAL;
|
||||
}
|
||||
conditions.SetUncacheable();
|
||||
} else {
|
||||
@@ -8134,32 +8121,20 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
||||
}
|
||||
|
||||
// justify-content: enum, inherit, initial
|
||||
const auto& justifyContentValue = *aRuleData->ValueForJustifyContent();
|
||||
if (MOZ_UNLIKELY(justifyContentValue.GetUnit() == eCSSUnit_Inherit)) {
|
||||
if (MOZ_LIKELY(parentContext)) {
|
||||
pos->mJustifyContent =
|
||||
parentPos->ComputedJustifyContent(parentContext->StyleDisplay());
|
||||
} else {
|
||||
pos->mJustifyContent = NS_STYLE_JUSTIFY_AUTO;
|
||||
}
|
||||
conditions.SetUncacheable();
|
||||
} else {
|
||||
SetDiscrete(justifyContentValue,
|
||||
pos->mJustifyContent, conditions,
|
||||
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
|
||||
parentPos->mJustifyContent, // unused, we handle 'inherit' above
|
||||
NS_STYLE_JUSTIFY_AUTO, 0, 0, 0, 0);
|
||||
}
|
||||
SetDiscrete(*aRuleData->ValueForJustifyContent(),
|
||||
pos->mJustifyContent, conditions,
|
||||
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
|
||||
parentPos->mJustifyContent,
|
||||
NS_STYLE_JUSTIFY_NORMAL, 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);
|
||||
parentPos->ComputedJustifyItems(parentContext->GetParent());
|
||||
} else {
|
||||
pos->mJustifyItems = NS_STYLE_JUSTIFY_AUTO;
|
||||
pos->mJustifyItems = NS_STYLE_JUSTIFY_NORMAL;
|
||||
}
|
||||
conditions.SetUncacheable();
|
||||
} else {
|
||||
@@ -8178,11 +8153,9 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
|
||||
if (MOZ_LIKELY(grandparentContext)) {
|
||||
parentContext->AddStyleBit(NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE);
|
||||
}
|
||||
pos->mJustifySelf =
|
||||
parentPos->ComputedJustifySelf(parentContext->StyleDisplay(),
|
||||
grandparentContext);
|
||||
pos->mJustifySelf = parentPos->ComputedJustifySelf(grandparentContext);
|
||||
} else {
|
||||
pos->mJustifySelf = NS_STYLE_JUSTIFY_START;
|
||||
pos->mJustifySelf = NS_STYLE_JUSTIFY_NORMAL;
|
||||
}
|
||||
conditions.SetUncacheable();
|
||||
} else {
|
||||
|
||||
@@ -473,29 +473,31 @@ enum class FillMode : uint32_t;
|
||||
|
||||
// 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 & UNSAFE
|
||||
#define NS_STYLE_ALIGN_SAFE 0x20
|
||||
#define NS_STYLE_ALIGN_UNSAFE 0x40 // mutually exclusive w. SAFE
|
||||
#define NS_STYLE_ALIGN_FLAG_BITS 0xF0
|
||||
#define NS_STYLE_ALIGN_NORMAL 1
|
||||
#define NS_STYLE_ALIGN_START 2
|
||||
#define NS_STYLE_ALIGN_END 3
|
||||
#define NS_STYLE_ALIGN_FLEX_START 4
|
||||
#define NS_STYLE_ALIGN_FLEX_END 5
|
||||
#define NS_STYLE_ALIGN_CENTER 6
|
||||
#define NS_STYLE_ALIGN_LEFT 7
|
||||
#define NS_STYLE_ALIGN_RIGHT 8
|
||||
#define NS_STYLE_ALIGN_BASELINE 9
|
||||
#define NS_STYLE_ALIGN_LAST_BASELINE 10
|
||||
#define NS_STYLE_ALIGN_STRETCH 11
|
||||
#define NS_STYLE_ALIGN_SELF_START 12
|
||||
#define NS_STYLE_ALIGN_SELF_END 13
|
||||
#define NS_STYLE_ALIGN_SPACE_BETWEEN 14
|
||||
#define NS_STYLE_ALIGN_SPACE_AROUND 15
|
||||
#define NS_STYLE_ALIGN_SPACE_EVENLY 16
|
||||
#define NS_STYLE_ALIGN_LEGACY 0x20 // mutually exclusive w. SAFE & UNSAFE
|
||||
#define NS_STYLE_ALIGN_SAFE 0x40
|
||||
#define NS_STYLE_ALIGN_UNSAFE 0x80 // mutually exclusive w. SAFE
|
||||
#define NS_STYLE_ALIGN_FLAG_BITS 0xE0
|
||||
#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_NORMAL NS_STYLE_ALIGN_NORMAL
|
||||
#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
|
||||
|
||||
@@ -1396,10 +1396,10 @@ nsStylePosition::nsStylePosition(void)
|
||||
|
||||
mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_ROW;
|
||||
mBoxSizing = StyleBoxSizing::Content;
|
||||
mAlignContent = NS_STYLE_ALIGN_AUTO;
|
||||
mAlignItems = NS_STYLE_ALIGN_AUTO;
|
||||
mAlignContent = NS_STYLE_ALIGN_NORMAL;
|
||||
mAlignItems = NS_STYLE_ALIGN_NORMAL;
|
||||
mAlignSelf = NS_STYLE_ALIGN_AUTO;
|
||||
mJustifyContent = NS_STYLE_JUSTIFY_AUTO;
|
||||
mJustifyContent = NS_STYLE_JUSTIFY_NORMAL;
|
||||
mJustifyItems = NS_STYLE_JUSTIFY_AUTO;
|
||||
mJustifySelf = NS_STYLE_JUSTIFY_AUTO;
|
||||
mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
|
||||
@@ -1645,90 +1645,50 @@ nsStylePosition::WidthCoordDependsOnContainer(const nsStyleCoord &aCoord)
|
||||
}
|
||||
|
||||
uint8_t
|
||||
nsStylePosition::ComputedAlignItems(const nsStyleDisplay* aDisplay) const
|
||||
{
|
||||
if (mAlignItems != NS_STYLE_ALIGN_AUTO) {
|
||||
return mAlignItems;
|
||||
}
|
||||
return aDisplay->IsFlexOrGridDisplayType() ? NS_STYLE_ALIGN_STRETCH
|
||||
: NS_STYLE_ALIGN_START;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
nsStylePosition::ComputedAlignSelf(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const
|
||||
nsStylePosition::ComputedAlignSelf(nsStyleContext* aParent) const
|
||||
{
|
||||
if (mAlignSelf != NS_STYLE_ALIGN_AUTO) {
|
||||
return mAlignSelf;
|
||||
}
|
||||
if (MOZ_UNLIKELY(aDisplay->IsAbsolutelyPositionedStyle())) {
|
||||
return NS_STYLE_ALIGN_AUTO;
|
||||
}
|
||||
if (MOZ_LIKELY(aParent)) {
|
||||
auto parentAlignItems = aParent->StylePosition()->
|
||||
ComputedAlignItems(aParent->StyleDisplay());
|
||||
auto parentAlignItems = aParent->StylePosition()->ComputedAlignItems();
|
||||
MOZ_ASSERT(!(parentAlignItems & NS_STYLE_ALIGN_LEGACY),
|
||||
"align-items can't have 'legacy'");
|
||||
return parentAlignItems;
|
||||
}
|
||||
return NS_STYLE_ALIGN_START;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
nsStylePosition::ComputedJustifyContent(const nsStyleDisplay* aDisplay) const
|
||||
{
|
||||
switch (aDisplay->mDisplay) {
|
||||
case NS_STYLE_DISPLAY_FLEX:
|
||||
case NS_STYLE_DISPLAY_INLINE_FLEX:
|
||||
// For flex containers, css-align-3 says the justify-content value
|
||||
// "'stretch' computes to 'flex-start'."
|
||||
// https://drafts.csswg.org/css-align-3/#propdef-justify-content
|
||||
// XXX maybe map 'auto' too? (ISSUE 8 in the spec)
|
||||
// https://drafts.csswg.org/css-align-3/#content-distribution
|
||||
if ((mJustifyContent & NS_STYLE_ALIGN_ALL_BITS) ==
|
||||
NS_STYLE_JUSTIFY_STRETCH) {
|
||||
return NS_STYLE_JUSTIFY_FLEX_START;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return mJustifyContent;
|
||||
return NS_STYLE_ALIGN_NORMAL;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
nsStylePosition::ComputedJustifyItems(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const
|
||||
nsStylePosition::ComputedJustifyItems(nsStyleContext* aParent) const
|
||||
{
|
||||
if (mJustifyItems != NS_STYLE_JUSTIFY_AUTO) {
|
||||
return mJustifyItems;
|
||||
}
|
||||
if (MOZ_LIKELY(aParent)) {
|
||||
auto inheritedJustifyItems =
|
||||
aParent->StylePosition()->ComputedJustifyItems(aParent->StyleDisplay(),
|
||||
aParent->GetParent());
|
||||
aParent->StylePosition()->ComputedJustifyItems(aParent->GetParent());
|
||||
// "If the inherited value of justify-items includes the 'legacy' keyword,
|
||||
// 'auto' computes to the inherited value." Otherwise, 'normal'.
|
||||
if (inheritedJustifyItems & NS_STYLE_JUSTIFY_LEGACY) {
|
||||
return inheritedJustifyItems;
|
||||
}
|
||||
}
|
||||
return aDisplay->IsFlexOrGridDisplayType() ? NS_STYLE_JUSTIFY_STRETCH
|
||||
: NS_STYLE_JUSTIFY_START;
|
||||
return NS_STYLE_JUSTIFY_NORMAL;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
nsStylePosition::ComputedJustifySelf(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const
|
||||
nsStylePosition::ComputedJustifySelf(nsStyleContext* aParent) const
|
||||
{
|
||||
if (mJustifySelf != NS_STYLE_JUSTIFY_AUTO) {
|
||||
return mJustifySelf;
|
||||
}
|
||||
if (MOZ_UNLIKELY(aDisplay->IsAbsolutelyPositionedStyle())) {
|
||||
return NS_STYLE_JUSTIFY_AUTO;
|
||||
}
|
||||
if (MOZ_LIKELY(aParent)) {
|
||||
auto inheritedJustifyItems = aParent->StylePosition()->
|
||||
ComputedJustifyItems(aParent->StyleDisplay(), aParent->GetParent());
|
||||
ComputedJustifyItems(aParent->GetParent());
|
||||
return inheritedJustifyItems & ~NS_STYLE_JUSTIFY_LEGACY;
|
||||
}
|
||||
return NS_STYLE_JUSTIFY_START;
|
||||
return NS_STYLE_JUSTIFY_NORMAL;
|
||||
}
|
||||
|
||||
// --------------------
|
||||
|
||||
@@ -1440,37 +1440,32 @@ struct nsStylePosition {
|
||||
uint16_t ComputedAlignContent() const { return mAlignContent; }
|
||||
|
||||
/**
|
||||
* Return the computed value for 'align-items' given our 'display' value in
|
||||
* aDisplay.
|
||||
* Return the computed value for 'align-items'.
|
||||
*/
|
||||
uint8_t ComputedAlignItems(const nsStyleDisplay* aDisplay) const;
|
||||
uint8_t ComputedAlignItems() const { return mAlignItems; }
|
||||
|
||||
/**
|
||||
* Return the computed value for 'align-self' given our 'display' value in
|
||||
* aDisplay and the parent StyleContext aParent (or null for the root).
|
||||
* Return the computed value for 'align-self' given our parent StyleContext
|
||||
* aParent (or null for the root).
|
||||
*/
|
||||
uint8_t ComputedAlignSelf(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const;
|
||||
uint8_t ComputedAlignSelf(nsStyleContext* aParent) const;
|
||||
|
||||
/**
|
||||
* Return the computed value for 'justify-content' given our 'display' value
|
||||
* in aDisplay.
|
||||
* Return the computed value for 'justify-content'.
|
||||
*/
|
||||
uint16_t ComputedJustifyContent(const nsStyleDisplay* aDisplay) const;
|
||||
uint16_t ComputedJustifyContent() const { return mJustifyContent; }
|
||||
|
||||
/**
|
||||
* Return the computed value for 'justify-items' given our 'display' value in
|
||||
* aDisplay and the parent StyleContext aParent (or null for the root).
|
||||
* Return the computed value for 'justify-items' given our parent StyleContext
|
||||
* aParent (or null for the root).
|
||||
*/
|
||||
uint8_t ComputedJustifyItems(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const;
|
||||
uint8_t ComputedJustifyItems(nsStyleContext* aParent) const;
|
||||
|
||||
/**
|
||||
* Return the computed value for 'justify-self' given our 'display' value in
|
||||
* aDisplay and the parent StyleContext aParent (or null for the root).
|
||||
* Return the computed value for 'justify-self' given our parent StyleContext
|
||||
* aParent (or null for the root).
|
||||
*/
|
||||
uint8_t ComputedJustifySelf(const nsStyleDisplay* aDisplay,
|
||||
nsStyleContext* aParent) const;
|
||||
uint8_t ComputedJustifySelf(nsStyleContext* aParent) const;
|
||||
|
||||
Position mObjectPosition; // [reset]
|
||||
nsStyleSides mOffset; // [reset] coord, percent, calc, auto
|
||||
|
||||
Reference in New Issue
Block a user