Bug 1292609. Restyle ::-moz-xul-anonymous-block as needed with stylo. r?heycam draft
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 09 Aug 2017 16:39:58 -0400
changeset 643526 47886d49d91ec0db9db313fb52bfa85e775efbe9
parent 643520 94fbb3aa4061649736e0d8e6bb58323f0e037a3c
child 725323 c1611942a6812abca11f5518b8439dbd76b76c23
push id73123
push userbzbarsky@mozilla.com
push dateWed, 09 Aug 2017 20:40:10 +0000
reviewersheycam
bugs1292609
milestone57.0a1
Bug 1292609. Restyle ::-moz-xul-anonymous-block as needed with stylo. r?heycam MozReview-Commit-ID: KZ0s1x60VBx
layout/base/nsCSSFrameConstructor.cpp
layout/xul/nsBoxFrame.cpp
layout/xul/nsBoxFrame.h
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -11414,16 +11414,19 @@ nsCSSFrameConstructor::ProcessChildren(n
     ReparentFrames(this, blockFrame, aFrameItems, false);
 
     blockFrame->SetInitialChildList(kPrincipalList, aFrameItems);
     NS_ASSERTION(aFrameItems.IsEmpty(), "How did that happen?");
     aFrameItems.Clear();
     aFrameItems.AddChild(blockFrame);
 
     aFrame->AddStateBits(NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK);
+    MOZ_ASSERT(!aFrame->IsLeaf(),
+               "Why do we have an nsLeafBoxFrame here?");
+    aFrame->AddStateBits(NS_FRAME_OWNS_ANON_BOXES);
   }
 }
 
 //----------------------------------------------------------------------
 
 // Support for :first-line style
 
 // Special routine to handle placing a list of frames into a block
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -1903,16 +1903,24 @@ nsBoxFrame::RegUnregAccessKey(bool aDoRe
 }
 
 bool
 nsBoxFrame::SupportsOrdinalsInChildren()
 {
   return true;
 }
 
+void
+nsBoxFrame::AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult)
+{
+  if (GetStateBits() & NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK) {
+    aResult.AppendElement(OwnedAnonBox(PrincipalChildList().FirstChild()));
+  }
+}
+
 // Helper less-than-or-equal function, used in CheckBoxOrder() as a
 // template-parameter for the sorting functions.
 bool
 IsBoxOrdinalLEQ(nsIFrame* aFrame1,
                 nsIFrame* aFrame2)
 {
   // If we've got a placeholder frame, use its out-of-flow frame's ordinal val.
   nsIFrame* aRealFrame1 = nsPlaceholderFrame::GetRealFrameFor(aFrame1);
--- a/layout/xul/nsBoxFrame.h
+++ b/layout/xul/nsBoxFrame.h
@@ -166,16 +166,21 @@ public:
                              const nsDisplayListSet& aOut);
 
   /**
    * This defaults to true, but some box frames (nsListBoxBodyFrame for
    * example) don't support ordinals in their children.
    */
   virtual bool SupportsOrdinalsInChildren();
 
+  /**
+   * Return our wrapper block, if any.
+   */
+  void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
+
 private:
   explicit nsBoxFrame(nsStyleContext* aContext)
     : nsBoxFrame(aContext, kClassID, false, nullptr) {}
 protected:
   nsBoxFrame(nsStyleContext* aContext, ClassID aID, bool aIsRoot = false,
              nsBoxLayout* aLayoutManager = nullptr);
   virtual ~nsBoxFrame();