Bug 1322570 Part 2 - Resolve {align,justify}-self using StyleContext from alignment container frame in ReflowInput::InitConstraints(). r=dholbert

Per bug 1322570 comment 46, it's not easy to replace ComputedJustifyItems()
and UsedJustifySelf()'s internal nsStyleContext::GetParent() without
correctness penalty, so we use GetParentAllowServo() for now.

Also, fix the reftest.list added in bug 1334403 which incorrectly wrote test
page as reference page.

MozReview-Commit-ID: 6kAAWSFojd5
This commit is contained in:
Ting-Yu Lin
2017-03-20 14:12:08 +08:00
parent fefa431928
commit 6b854b6f48
5 changed files with 11 additions and 9 deletions

View File

@@ -2399,9 +2399,10 @@ ReflowInput::InitConstraints(nsPresContext* aPresContext,
if (alignCBType == nsGkAtoms::gridContainerFrame) { if (alignCBType == nsGkAtoms::gridContainerFrame) {
// Shrink-wrap grid items that will be aligned (rather than stretched) // Shrink-wrap grid items that will be aligned (rather than stretched)
// in its inline axis. // in its inline axis.
auto inlineAxisAlignment = wm.IsOrthogonalTo(cbwm) ? auto inlineAxisAlignment =
mStylePosition->UsedAlignSelf(mFrame->StyleContext()->GetParent()) : wm.IsOrthogonalTo(cbwm)
mStylePosition->UsedJustifySelf(mFrame->StyleContext()->GetParent()); ? mStylePosition->UsedAlignSelf(alignCB->StyleContext())
: mStylePosition->UsedJustifySelf(alignCB->StyleContext());
if ((inlineAxisAlignment != NS_STYLE_ALIGN_STRETCH && if ((inlineAxisAlignment != NS_STYLE_ALIGN_STRETCH &&
inlineAxisAlignment != NS_STYLE_ALIGN_NORMAL) || inlineAxisAlignment != NS_STYLE_ALIGN_NORMAL) ||
mStyleMargin->mMargin.GetIStartUnit(wm) == eStyleUnit_Auto || mStyleMargin->mMargin.GetIStartUnit(wm) == eStyleUnit_Auto ||

View File

@@ -26,6 +26,7 @@ table {
background: lightgrey; background: lightgrey;
} }
caption { border: 1px dashed blue; } caption { border: 1px dashed blue; }
caption { justify-self: stretch; } /* XXX: Workaround bug 1350037. */
x { display:block; width:16px; height:16px; } x { display:block; width:16px; height:16px; }
t { display:block; width:6px; height:6px; } t { display:block; width:6px; height:6px; }

View File

@@ -4654,7 +4654,7 @@ nsComputedDOMStyle::DoGetJustifyItems()
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue; RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
nsAutoString str; nsAutoString str;
auto justify = auto justify =
StylePosition()->ComputedJustifyItems(mStyleContext->GetParent()); StylePosition()->ComputedJustifyItems(mStyleContext->GetParentAllowServo());
nsCSSValue::AppendAlignJustifyValueToString(justify, str); nsCSSValue::AppendAlignJustifyValueToString(justify, str);
val->SetString(str); val->SetString(str);
return val.forget(); return val.forget();

View File

@@ -8676,7 +8676,7 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
if (MOZ_UNLIKELY(justifyItemsValue.GetUnit() == eCSSUnit_Inherit)) { if (MOZ_UNLIKELY(justifyItemsValue.GetUnit() == eCSSUnit_Inherit)) {
if (MOZ_LIKELY(parentContext)) { if (MOZ_LIKELY(parentContext)) {
pos->mJustifyItems = pos->mJustifyItems =
parentPos->ComputedJustifyItems(parentContext->GetParent()); parentPos->ComputedJustifyItems(parentContext->GetParentAllowServo());
} else { } else {
pos->mJustifyItems = NS_STYLE_JUSTIFY_NORMAL; pos->mJustifyItems = NS_STYLE_JUSTIFY_NORMAL;
} }

View File

@@ -1678,8 +1678,8 @@ nsStylePosition::ComputedJustifyItems(nsStyleContext* aParent) const
return mJustifyItems; return mJustifyItems;
} }
if (MOZ_LIKELY(aParent)) { if (MOZ_LIKELY(aParent)) {
auto inheritedJustifyItems = auto inheritedJustifyItems = aParent->StylePosition()->ComputedJustifyItems(
aParent->StylePosition()->ComputedJustifyItems(aParent->GetParent()); aParent->GetParentAllowServo());
// "If the inherited value of justify-items includes the 'legacy' keyword, // "If the inherited value of justify-items includes the 'legacy' keyword,
// 'auto' computes to the inherited value." Otherwise, 'normal'. // 'auto' computes to the inherited value." Otherwise, 'normal'.
if (inheritedJustifyItems & NS_STYLE_JUSTIFY_LEGACY) { if (inheritedJustifyItems & NS_STYLE_JUSTIFY_LEGACY) {
@@ -1696,8 +1696,8 @@ nsStylePosition::UsedJustifySelf(nsStyleContext* aParent) const
return mJustifySelf; return mJustifySelf;
} }
if (MOZ_LIKELY(aParent)) { if (MOZ_LIKELY(aParent)) {
auto inheritedJustifyItems = aParent->StylePosition()-> auto inheritedJustifyItems = aParent->StylePosition()->ComputedJustifyItems(
ComputedJustifyItems(aParent->GetParent()); aParent->GetParentAllowServo());
return inheritedJustifyItems & ~NS_STYLE_JUSTIFY_LEGACY; return inheritedJustifyItems & ~NS_STYLE_JUSTIFY_LEGACY;
} }
return NS_STYLE_JUSTIFY_NORMAL; return NS_STYLE_JUSTIFY_NORMAL;