--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -82,37 +82,34 @@ kAxisOrientationToSidesMap[eNumAxisOrien
// Returns true iff the given nsStyleDisplay has display:-webkit-{inline-}-box.
static inline bool
IsDisplayValueLegacyBox(const nsStyleDisplay* aStyleDisp)
{
return aStyleDisp->mDisplay == mozilla::StyleDisplay::WebkitBox ||
aStyleDisp->mDisplay == mozilla::StyleDisplay::WebkitInlineBox;
}
-// Helper to check whether our nsFlexContainerFrame is emulating a legacy
-// -webkit-{inline-}box, in which case we should use legacy CSS properties
-// instead of the modern ones. The params are are the nsStyleDisplay and the
-// nsStyleContext associated with the nsFlexContainerFrame itself.
-static inline bool
-IsLegacyBox(const nsStyleDisplay* aStyleDisp,
- nsStyleContext* aStyleContext)
+/* static */ bool
+nsFlexContainerFrame::IsLegacyBox(const nsIFrame* aFrame)
{
+ nsStyleContext* styleContext = aFrame->StyleContext();
+ const nsStyleDisplay* styleDisp = styleContext->StyleDisplay();
// Trivial case: just check "display" directly.
- if (IsDisplayValueLegacyBox(aStyleDisp)) {
+ if (IsDisplayValueLegacyBox(styleDisp)) {
return true;
}
// If this frame is for a scrollable element, then it will actually have
// "display:block", and its *parent* will have the real flex-flavored display
// value. So in that case, check the parent to find out if we're legacy.
- if (aStyleDisp->mDisplay == mozilla::StyleDisplay::Block) {
- nsStyleContext* parentStyleContext = aStyleContext->GetParent();
+ if (styleDisp->mDisplay == mozilla::StyleDisplay::Block) {
+ nsStyleContext* parentStyleContext = styleContext->GetParent();
NS_ASSERTION(parentStyleContext &&
- (aStyleContext->GetPseudo() == nsCSSAnonBoxes::buttonContent ||
- aStyleContext->GetPseudo() == nsCSSAnonBoxes::scrolledContent),
+ (styleContext->GetPseudo() == nsCSSAnonBoxes::buttonContent ||
+ styleContext->GetPseudo() == nsCSSAnonBoxes::scrolledContent),
"The only way a nsFlexContainerFrame can have 'display:block' "
"should be if it's the inner part of a scrollable or button "
"element");
if (IsDisplayValueLegacyBox(parentStyleContext->StyleDisplay())) {
return true;
}
}
@@ -1065,19 +1062,17 @@ GetFirstNonAnonBoxDescendant(nsIFrame* a
bool
IsOrderLEQWithDOMFallback(nsIFrame* aFrame1,
nsIFrame* aFrame2)
{
MOZ_ASSERT(aFrame1->IsFlexItem() && aFrame2->IsFlexItem(),
"this method only intended for comparing flex items");
MOZ_ASSERT(aFrame1->GetParent() == aFrame2->GetParent(),
"this method only intended for comparing siblings");
- nsStyleContext* parentFrameSC = aFrame1->GetParent()->StyleContext();
- bool isInLegacyBox = IsLegacyBox(parentFrameSC->StyleDisplay(),
- parentFrameSC);
+ bool isInLegacyBox = nsFlexContainerFrame::IsLegacyBox(aFrame1->GetParent());
if (aFrame1 == aFrame2) {
// Anything is trivially LEQ itself, so we return "true" here... but it's
// probably bad if we end up actually needing this, so let's assert.
NS_ERROR("Why are we checking if a frame is LEQ itself?");
return true;
}
@@ -1151,19 +1146,17 @@ IsOrderLEQWithDOMFallback(nsIFrame* aFra
bool
IsOrderLEQ(nsIFrame* aFrame1,
nsIFrame* aFrame2)
{
MOZ_ASSERT(aFrame1->IsFlexItem() && aFrame2->IsFlexItem(),
"this method only intended for comparing flex items");
MOZ_ASSERT(aFrame1->GetParent() == aFrame2->GetParent(),
"this method only intended for comparing siblings");
- nsStyleContext* parentFrameSC = aFrame1->GetParent()->StyleContext();
- bool isInLegacyBox = IsLegacyBox(parentFrameSC->StyleDisplay(),
- parentFrameSC);
+ bool isInLegacyBox = nsFlexContainerFrame::IsLegacyBox(aFrame1->GetParent());
// If we've got a placeholder frame, use its out-of-flow frame's 'order' val.
nsIFrame* aRealFrame1 = nsPlaceholderFrame::GetRealFrameFor(aFrame1);
nsIFrame* aRealFrame2 = nsPlaceholderFrame::GetRealFrameFor(aFrame2);
int32_t order1 = GetOrderOrBoxOrdinalGroup(aRealFrame1, isInLegacyBox);
int32_t order2 = GetOrderOrBoxOrdinalGroup(aRealFrame2, isInLegacyBox);
@@ -1189,17 +1182,17 @@ nsFlexContainerFrame::GenerateFlexItemFo
// (This reflow state will _not_ be used for reflow.)
ReflowInput
childRI(aPresContext, aParentReflowInput, aChildFrame,
aParentReflowInput.ComputedSize(aChildFrame->GetWritingMode()));
// FLEX GROW & SHRINK WEIGHTS
// --------------------------
float flexGrow, flexShrink;
- if (IsLegacyBox(aParentReflowInput.mStyleDisplay, mStyleContext)) {
+ if (IsLegacyBox(this)) {
flexGrow = flexShrink = aChildFrame->StyleXUL()->mBoxFlex;
} else {
const nsStylePosition* stylePos = aChildFrame->StylePosition();
flexGrow = stylePos->mFlexGrow;
flexShrink = stylePos->mFlexShrink;
}
WritingMode childWM = childRI.GetWritingMode();
@@ -1702,18 +1695,17 @@ FlexItem::FlexItem(ReflowInput& aFlexIte
{
MOZ_ASSERT(mFrame, "expecting a non-null child frame");
MOZ_ASSERT(mFrame->GetType() != nsGkAtoms::placeholderFrame,
"placeholder frames should not be treated as flex items");
MOZ_ASSERT(!(mFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW),
"out-of-flow frames should not be treated as flex items");
const ReflowInput* containerRS = aFlexItemReflowInput.mParentReflowInput;
- if (IsLegacyBox(containerRS->mStyleDisplay,
- containerRS->mFrame->StyleContext())) {
+ if (IsLegacyBox(containerRS->mFrame)) {
// For -webkit-box/-webkit-inline-box, we need to:
// (1) Use "-webkit-box-align" instead of "align-items" to determine the
// container's cross-axis alignment behavior.
// (2) Suppress the ability for flex items to override that with their own
// cross-axis alignment. (The legacy box model doesn't support this.)
// So, each FlexItem simply copies the container's converted "align-items"
// value and disregards their own "align-self" property.
const nsStyleXUL* containerStyleXUL = containerRS->mFrame->StyleXUL();
@@ -3235,18 +3227,17 @@ BlockDirToAxisOrientation(WritingMode::B
}
FlexboxAxisTracker::FlexboxAxisTracker(
const nsFlexContainerFrame* aFlexContainer,
const WritingMode& aWM)
: mWM(aWM),
mAreAxesInternallyReversed(false)
{
- if (IsLegacyBox(aFlexContainer->StyleDisplay(),
- aFlexContainer->StyleContext())) {
+ if (IsLegacyBox(aFlexContainer)) {
InitAxesFromLegacyProps(aFlexContainer);
} else {
InitAxesFromModernProps(aFlexContainer);
}
// Master switch to enable/disable bug 983427's code for reversing our axes
// and reversing some logic, to avoid reflowing children in bottom-to-top
// order. (This switch can be removed eventually, but for now, it allows
@@ -4134,18 +4125,17 @@ nsFlexContainerFrame::DoFlexLayout(nsPre
} else {
flexContainerAscent =
ComputePhysicalAscentFromFlexRelativeAscent(
crossAxisPosnTracker.GetPosition() + firstLineBaselineOffset,
contentBoxCrossSize, aReflowInput, aAxisTracker);
}
}
- const auto justifyContent = IsLegacyBox(aReflowInput.mStyleDisplay,
- mStyleContext) ?
+ const auto justifyContent = IsLegacyBox(aReflowInput.mFrame) ?
ConvertLegacyStyleToJustifyContent(StyleXUL()) :
aReflowInput.mStylePosition->mJustifyContent;
for (FlexLine* line = lines.getFirst(); line; line = line->getNext()) {
// Main-Axis Alignment - Flexbox spec section 9.5
// ==============================================
line->PositionItemsInMainAxis(justifyContent,
aContentBoxMainSize,
--- a/layout/generic/nsFlexContainerFrame.h
+++ b/layout/generic/nsFlexContainerFrame.h
@@ -97,16 +97,22 @@ public:
* space to be divided up.
*/
static void CalculatePackingSpace(uint32_t aNumThingsToPack,
uint8_t aAlignVal,
nscoord* aFirstSubjectOffset,
uint32_t* aNumPackingSpacesRemaining,
nscoord* aPackingSpaceRemaining);
+ /**
+ * Returns true if aFrame is the frame for an element with
+ * "display:-webkit-box" or "display:-webkit-inline-box".
+ */
+ static bool IsLegacyBox(const nsIFrame* aFrame);
+
protected:
// Protected constructor & destructor
explicit nsFlexContainerFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
, mBaselineFromLastReflow(NS_INTRINSIC_WIDTH_UNKNOWN)
{}
virtual ~nsFlexContainerFrame();