Bug 1398963 part 2: Make nsFlexContainerFrame label itself as legacy if it has -moz-box/-moz-inline-box display val. r?mats draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 18 Dec 2017 12:17:10 -0600
changeset 712750 8aa9dfdb6b275bd5cd90da070576017b383e0e97
parent 712749 308c3edc34ca5b804db7b83b5d815d658ce1f47a
child 712751 3cae633e1a7b863d18527670ea862faa93a345e7
push id93413
push userdholbert@mozilla.com
push dateMon, 18 Dec 2017 18:17:28 +0000
reviewersmats
bugs1398963
milestone59.0a1
Bug 1398963 part 2: Make nsFlexContainerFrame label itself as legacy if it has -moz-box/-moz-inline-box display val. r?mats To be clear, this is a "paving the way" patch. At this point in the patch series, it's not yet possible for us to generate a nsFlexContainerFrame that has display:-moz-box. (A later patch in this series will make that possible.) This patch adds the mechanics to nsFlexContainerFrame instances so that they'll label themselves appropriately (with NS_STATE_FLEX_IS_EMULATING_LEGACY_BOX) once it *does* become possible for -moz-box to spawn a nsFlexContainerFrame. Moreover, this patch updates the state bit's documentation to reflect its new potential-usage. MozReview-Commit-ID: ElApieVoTLf
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsFrameStateBits.h
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -76,26 +76,29 @@ kAxisOrientationToSidesMap[eNumAxisOrien
   { eSideLeft,   eSideRight  },  // eAxis_LR
   { eSideRight,  eSideLeft   },  // eAxis_RL
   { eSideTop,    eSideBottom },  // eAxis_TB
   { eSideBottom, eSideTop }      // eAxis_BT
 };
 
 // Helper structs / classes / methods
 // ==================================
-// Returns true iff the given nsStyleDisplay has display:-webkit-{inline-}-box.
+// Returns true iff the given nsStyleDisplay has display:-webkit-{inline-}box
+// or display:-moz-{inline-}box.
 static inline bool
 IsDisplayValueLegacyBox(const nsStyleDisplay* aStyleDisp)
 {
   return aStyleDisp->mDisplay == mozilla::StyleDisplay::WebkitBox ||
-    aStyleDisp->mDisplay == mozilla::StyleDisplay::WebkitInlineBox;
+    aStyleDisp->mDisplay == mozilla::StyleDisplay::WebkitInlineBox ||
+    aStyleDisp->mDisplay == mozilla::StyleDisplay::MozBox ||
+    aStyleDisp->mDisplay == mozilla::StyleDisplay::MozInlineBox;
 }
 
-// Returns true if aFlexContainer is the frame for an element with
-// "display:-webkit-box" or "display:-webkit-inline-box". aFlexContainer is
+// Returns true if aFlexContainer is a frame for some element that has
+// display:-webkit-{inline-}box (or -moz-{inline-}box). aFlexContainer is
 // expected to be an instance of nsFlexContainerFrame (enforced with an assert);
 // otherwise, this function's state-bit-check here is bogus.
 static bool
 IsLegacyBox(const nsIFrame* aFlexContainer)
 {
   MOZ_ASSERT(aFlexContainer->IsFlexContainerFrame(),
              "only flex containers may be passed to this function");
   return aFlexContainer->HasAnyStateBits(NS_STATE_FLEX_IS_EMULATING_LEGACY_BOX);
@@ -1808,18 +1811,18 @@ FlexItem::FlexItem(ReflowInput& aFlexIte
   MOZ_ASSERT(mFrame, "expecting a non-null child frame");
   MOZ_ASSERT(!mFrame->IsPlaceholderFrame(),
              "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->mFrame)) {
-    // For -webkit-box/-webkit-inline-box, we need to:
-    // (1) Use "-webkit-box-align" instead of "align-items" to determine the
+    // For -webkit-{inline-}box and -moz-{inline-}box, we need to:
+    // (1) Use prefixed "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();
     mAlignSelf = ConvertLegacyStyleToAlignItems(containerStyleXUL);
   } else {
@@ -2218,17 +2221,17 @@ nsFlexContainerFrame::Init(nsIContent*  
                            nsContainerFrame* aParent,
                            nsIFrame*         aPrevInFlow)
 {
   nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
 
   const nsStyleDisplay* styleDisp = StyleContext()->StyleDisplay();
 
   // Figure out if we should set a frame state bit to indicate that this frame
-  // represents a legacy -webkit-{inline-}box container.
+  // represents a legacy -webkit-{inline-}box or -moz-{inline-}box container.
   // First, the trivial case: just check "display" directly.
   bool isLegacyBox = IsDisplayValueLegacyBox(styleDisp);
 
   // If this frame is for a scrollable element, then it will actually have
   // "display:block", and its *parent frame* will have the real
   // flex-flavored display value. So in that case, check the parent frame to
   // find out if we're legacy.
   if (!isLegacyBox && styleDisp->mDisplay == mozilla::StyleDisplay::Block) {
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -315,17 +315,17 @@ FRAME_STATE_BIT(Box, 61, NS_FRAME_MOUSE_
 
 FRAME_STATE_GROUP(FlexContainer, nsFlexContainerFrame)
 
 // True iff the normal flow children are already in CSS 'order' in the
 // order they occur in the child frame list.
 FRAME_STATE_BIT(FlexContainer, 20, NS_STATE_FLEX_NORMAL_FLOW_CHILDREN_IN_CSS_ORDER)
 
 // Set for a flex container that is emulating a legacy
-// 'display:-webkit-{inline-}box' container.
+// 'display:-webkit-{inline-}box' or 'display:-moz-{inline-}box' container.
 FRAME_STATE_BIT(FlexContainer, 21, NS_STATE_FLEX_IS_EMULATING_LEGACY_BOX)
 
 // True iff computed flex values should be generated on the next reflow
 FRAME_STATE_BIT(FlexContainer, 22, NS_STATE_FLEX_GENERATE_COMPUTED_VALUES)
 
 // True if the container has no flex items; may lie if there is a pending reflow
 FRAME_STATE_BIT(FlexContainer, 23, NS_STATE_FLEX_SYNTHESIZE_BASELINE)