Bug 907396 - Flex/Grid container changes for display:contents. r=dholbert

This commit is contained in:
Mats Palmgren 2014-11-20 18:24:09 +00:00
parent ca5235fd31
commit 02d2f75bc9

View File

@ -509,8 +509,21 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
// Any direct children of elements with Ruby display values which are // Any direct children of elements with Ruby display values which are
// block-level are converted to their inline-level equivalents. // block-level are converted to their inline-level equivalents.
if (!aSkipParentDisplayBasedStyleFixup && mParent) { if (!aSkipParentDisplayBasedStyleFixup && mParent) {
const nsStyleDisplay* parentDisp = mParent->StyleDisplay(); // Skip display:contents ancestors to reach the potential container.
if (parentDisp->IsFlexOrGridDisplayType() && // (If there are only display:contents ancestors between this node and
// a flex/grid container ancestor, then this node is a flex/grid item, since
// its parent *in the frame tree* will be the flex/grid container. So we treat
// it like a flex/grid item here.)
nsStyleContext* containerContext = mParent;
const nsStyleDisplay* containerDisp = containerContext->StyleDisplay();
while (containerDisp->mDisplay == NS_STYLE_DISPLAY_CONTENTS) {
if (!containerContext->GetParent()) {
break;
}
containerContext = containerContext->GetParent();
containerDisp = containerContext->StyleDisplay();
}
if (containerDisp->IsFlexOrGridDisplayType() &&
GetPseudo() != nsCSSAnonBoxes::mozNonElement) { GetPseudo() != nsCSSAnonBoxes::mozNonElement) {
uint8_t displayVal = disp->mDisplay; uint8_t displayVal = disp->mDisplay;
// Skip table parts. // Skip table parts.
@ -544,7 +557,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
mutable_display->mDisplay = displayVal; mutable_display->mDisplay = displayVal;
} }
} }
} else if (parentDisp->IsRubyDisplayType()) { } else if (containerDisp->IsRubyDisplayType()) {
uint8_t displayVal = disp->mDisplay; uint8_t displayVal = disp->mDisplay;
nsRuleNode::EnsureInlineDisplay(displayVal); nsRuleNode::EnsureInlineDisplay(displayVal);
// The display change should only occur for "in-flow" children // The display change should only occur for "in-flow" children