Bug 1320484 part 2: Wrap abspos placeholders in anonymous flex items, in flex containers that are really emulating legacy -webkit-box containers. r?mats draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 04 Jan 2017 20:31:17 -0800
changeset 456208 5f0add6689ed0fd85ff7bfc777bea1806df6d2c6
parent 456207 971360ba52c02edb41731b6566dd0271b6e9396f
child 456209 f6493e84695d91bbf1fc6a2c639cafc1d9d6d43f
child 456211 94db004d4def732317e5a4d40dd5aa592f565de5
child 456212 d4b2a813fcef2c609e8a2825e96f255817bddf06
push id40421
push userdholbert@mozilla.com
push dateThu, 05 Jan 2017 04:32:08 +0000
reviewersmats
bugs1320484, 1269045
milestone53.0a1
Bug 1320484 part 2: Wrap abspos placeholders in anonymous flex items, in flex containers that are really emulating legacy -webkit-box containers. r?mats This changeset is intended to revert the logic from "Bug 1269045 part 3" [1], *specifically* for legacy "-webkit-box"/"-webkit-inline-box" flex containers. [1] https://hg.mozilla.org/mozilla-central/rev/707b2ab5879d MozReview-Commit-ID: vc4TuAoLai
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -10621,16 +10621,24 @@ FrameWantsToBeInAnonymousItem(const nsIF
              containerType == nsGkAtoms::gridContainerFrame);
 
   // Any line-participant frames (e.g. text) definitely want to be wrapped in
   // an anonymous flex/grid item.
   if (aFrame->IsFrameOfType(nsIFrame::eLineParticipant)) {
     return true;
   }
 
+  // If the container is a -webkit-box/-webkit-inline-box, then placeholders
+  // also need to be wrapped, for compatibility.
+  if (containerType == nsGkAtoms::flexContainerFrame &&
+      aContainerFrame->HasAnyStateBits(NS_STATE_FLEX_IS_LEGACY_WEBKIT_BOX) &&
+      aFrame->GetType() == nsGkAtoms::placeholderFrame) {
+    return true;
+  }
+
   return false;
 }
 #endif
 
 static void
 VerifyGridFlexContainerChildren(nsIFrame* aParentFrame,
                                 const nsFrameList& aChildren)
 {
@@ -12767,20 +12775,30 @@ nsCSSFrameConstructor::FrameConstruction
   NeedsAnonFlexOrGridItem(const nsFrameConstructorState& aState,
                           bool aIsWebkitBox)
 {
   if (mFCData->mBits & FCDATA_IS_LINE_PARTICIPANT) {
     // This will be an inline non-replaced box.
     return true;
   }
 
-  if (aIsWebkitBox &&
-      mStyleContext->StyleDisplay()->IsInlineOutsideStyle()) {
-    // In a -webkit-box, all inline-level content gets wrapped in an anon item.
-    return true;
+  if (aIsWebkitBox) {
+    if (mStyleContext->StyleDisplay()->IsInlineOutsideStyle()) {
+      // In a -webkit-box, all inline-level content gets wrapped in anon item.
+      return true;
+    }
+    if (!(mFCData->mBits & FCDATA_DISALLOW_OUT_OF_FLOW) &&
+        aState.GetGeometricParent(mStyleContext->StyleDisplay(), nullptr)) {
+      // We're abspos or fixedpos, which means we'll spawn a placeholder which
+      // (because our container is a -webkit-box) we'll need to wrap in an
+      // anonymous flex item.  So, we just treat _this_ frame as if _it_ needs
+      // to be wrapped in an anonymous flex item, and then when we spawn the
+      // placeholder, it'll end up in the right spot.
+      return true;
+    }
   }
 
   return false;
 }
 
 inline bool
 nsCSSFrameConstructor::FrameConstructionItemList::
 Iterator::SkipItemsThatNeedAnonFlexOrGridItem(