|
|
|
Lines 501-518
nsStyleContext::ApplyStyleFixups(bool aS
|
Link Here
|
|---|
|
| 501 |
// Adjust the "display" values of flex and grid items (but not for raw text, |
501 |
// Adjust the "display" values of flex and grid items (but not for raw text, |
| 502 |
// placeholders, or table-parts). CSS3 Flexbox section 4 says: |
502 |
// placeholders, or table-parts). CSS3 Flexbox section 4 says: |
| 503 |
// # The computed 'display' of a flex item is determined |
503 |
// # The computed 'display' of a flex item is determined |
| 504 |
// # by applying the table in CSS 2.1 Chapter 9.7. |
504 |
// # by applying the table in CSS 2.1 Chapter 9.7. |
| 505 |
// ...which converts inline-level elements to their block-level equivalents. |
505 |
// ...which converts inline-level elements to their block-level equivalents. |
| 506 |
// Any direct children of elements with Ruby display values which are |
506 |
// Any direct children of elements with Ruby display values which are |
| 507 |
// block-level are converted to their inline-level equivalents. |
507 |
// block-level are converted to their inline-level equivalents. |
| 508 |
if (!aSkipParentDisplayBasedStyleFixup && mParent) { |
508 |
if (!aSkipParentDisplayBasedStyleFixup && mParent) { |
| 509 |
const nsStyleDisplay* parentDisp = mParent->StyleDisplay(); |
509 |
// Skip display:contents ancestors to reach the potential container. |
| 510 |
if (parentDisp->IsFlexOrGridDisplayType() && |
510 |
// (If there are only display:contents ancestors between this node and |
|
|
511 |
// a flex/grid container ancestor, then this node is a flex/grid item, since |
| 512 |
// its parent *in the frame tree* will be the flex/grid container. So we treat |
| 513 |
// it like a flex/grid item here.) |
| 514 |
nsStyleContext* containerContext = mParent; |
| 515 |
const nsStyleDisplay* containerDisp = containerContext->StyleDisplay(); |
| 516 |
while (containerDisp->mDisplay == NS_STYLE_DISPLAY_CONTENTS) { |
| 517 |
if (!containerContext->GetParent()) { |
| 518 |
break; |
| 519 |
} |
| 520 |
containerContext = containerContext->GetParent(); |
| 521 |
containerDisp = containerContext->StyleDisplay(); |
| 522 |
} |
| 523 |
if (containerDisp->IsFlexOrGridDisplayType() && |
| 511 |
GetPseudo() != nsCSSAnonBoxes::mozNonElement) { |
524 |
GetPseudo() != nsCSSAnonBoxes::mozNonElement) { |
| 512 |
uint8_t displayVal = disp->mDisplay; |
525 |
uint8_t displayVal = disp->mDisplay; |
| 513 |
// Skip table parts. |
526 |
// Skip table parts. |
| 514 |
// NOTE: This list needs to be kept in sync with |
527 |
// NOTE: This list needs to be kept in sync with |
| 515 |
// nsCSSFrameConstructor.cpp's "sDisplayData" array -- specifically, |
528 |
// nsCSSFrameConstructor.cpp's "sDisplayData" array -- specifically, |
| 516 |
// this should be the list of display-values that have |
529 |
// this should be the list of display-values that have |
| 517 |
// FCDATA_DESIRED_PARENT_TYPE_TO_BITS specified in that array. |
530 |
// FCDATA_DESIRED_PARENT_TYPE_TO_BITS specified in that array. |
| 518 |
if (NS_STYLE_DISPLAY_TABLE_CAPTION != displayVal && |
531 |
if (NS_STYLE_DISPLAY_TABLE_CAPTION != displayVal && |
|
Lines 535-552
nsStyleContext::ApplyStyleFixups(bool aS
|
Link Here
|
|---|
|
| 535 |
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle(), |
548 |
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle(), |
| 536 |
"We shouldn't be changing the display value of " |
549 |
"We shouldn't be changing the display value of " |
| 537 |
"positioned content (and we should have already " |
550 |
"positioned content (and we should have already " |
| 538 |
"converted its display value to be block-level...)"); |
551 |
"converted its display value to be block-level...)"); |
| 539 |
nsStyleDisplay *mutable_display = |
552 |
nsStyleDisplay *mutable_display = |
| 540 |
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display)); |
553 |
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display)); |
| 541 |
mutable_display->mDisplay = displayVal; |
554 |
mutable_display->mDisplay = displayVal; |
| 542 |
} |
555 |
} |
| 543 |
} |
556 |
} |
| 544 |
} else if (parentDisp->IsRubyDisplayType()) { |
557 |
} else if (containerDisp->IsRubyDisplayType()) { |
| 545 |
uint8_t displayVal = disp->mDisplay; |
558 |
uint8_t displayVal = disp->mDisplay; |
| 546 |
nsRuleNode::EnsureInlineDisplay(displayVal); |
559 |
nsRuleNode::EnsureInlineDisplay(displayVal); |
| 547 |
// The display change should only occur for "in-flow" children |
560 |
// The display change should only occur for "in-flow" children |
| 548 |
if (displayVal != disp->mDisplay && |
561 |
if (displayVal != disp->mDisplay && |
| 549 |
!disp->IsOutOfFlowStyle()) { |
562 |
!disp->IsOutOfFlowStyle()) { |
| 550 |
nsStyleDisplay *mutable_display = |
563 |
nsStyleDisplay *mutable_display = |
| 551 |
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display)); |
564 |
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display)); |
| 552 |
mutable_display->mDisplay = displayVal; |
565 |
mutable_display->mDisplay = displayVal; |