Bug 1343948 - Merge overflow container children to next-in-flow's OverflowContainersProperty() if the property already exists. r=mats
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 02 Jun 2020 02:37:28 +0000
changeset 533429 adac15659f368493883afe5feeead8138f7b1141
parent 533428 e9507c0042be96c52728621968e255d1114e593e
child 533430 bc897315c3aff2141ceadb3bd7bdb08fe5c07b64
push id117738
push useraethanyc@gmail.com
push dateTue, 02 Jun 2020 02:39:10 +0000
treeherderautoland@adac15659f36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1343948
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1343948 - Merge overflow container children to next-in-flow's OverflowContainersProperty() if the property already exists. r=mats This is to prevent the assertion at the beginning of DrainExcessOverflowContainersList(). The invariant is described in the comment revised in this patch. That is, "only one overflow containers list exists for a given frame: either its own OverflowContainersProperty or its prev-in-flow's ExcessOverflowContainersProperty, not both." Differential Revision: https://phabricator.services.mozilla.com/D77328
layout/base/crashtests/crashtests.list
layout/generic/nsContainerFrame.cpp
layout/generic/nsContainerFrame.h
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -447,17 +447,17 @@ load 1288946-2b.html
 load 1297835.html
 load 1299736-1.html
 load 1308793.svg
 load 1308848-1.html
 load 1308848-2.html
 load 1338772-1.html
 load 1340571.html
 pref(dom.animations-api.implicit-keyframes.enabled,true) load 1343139-1.html
-asserts(0-1) asserts-if(Android,1-4) load 1343606.html # bug 1343948
+asserts-if(Android,0-3) load 1343606.html # bug 1642521
 load 1343937.html
 load 1352380.html
 load 1362423-1.html
 load 1381323.html
 load 1382534.html
 load 1388625-1.html
 load 1390389.html
 load 1391736.html
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -1724,17 +1724,28 @@ bool nsContainerFrame::PushIncompleteChi
   // Merge the results into our respective overflow child lists.
   if (!pushedList.IsEmpty()) {
     MergeSortedOverflow(pushedList);
   }
   if (!incompleteList.IsEmpty()) {
     MergeSortedOverflow(incompleteList);
   }
   if (!overflowIncompleteList.IsEmpty()) {
-    MergeSortedExcessOverflowContainers(overflowIncompleteList);
+    // If our next-in-flow already has overflow containers list, merge the
+    // overflowIncompleteList into that list. Otherwise, merge it into our
+    // excess overflow containers list, to be drained by our next-in-flow.
+    auto* nif = static_cast<nsContainerFrame*>(GetNextInFlow());
+    nsFrameList* oc =
+        nif ? nif->GetPropTableFrames(OverflowContainersProperty()) : nullptr;
+    if (oc) {
+      ReparentFrames(overflowIncompleteList, this, nif);
+      MergeSortedFrameLists(*oc, overflowIncompleteList, GetContent());
+    } else {
+      MergeSortedExcessOverflowContainers(overflowIncompleteList);
+    }
   }
   return true;
 }
 
 void nsContainerFrame::NormalizeChildLists() {
   MOZ_ASSERT(IsFlexOrGridContainer(),
              "Only Flex / Grid containers can call this!");
 
--- a/layout/generic/nsContainerFrame.h
+++ b/layout/generic/nsContainerFrame.h
@@ -283,45 +283,45 @@ class nsContainerFrame : public nsSplitt
                                 const ReflowOutput& aDesiredSize,
                                 const ReflowInput* aReflowInput, nscoord aX,
                                 nscoord aY, ReflowChildFlags aFlags);
 
   static void PositionChildViews(nsIFrame* aFrame);
 
   // ==========================================================================
   /* Overflow containers are continuation frames that hold overflow. They
-   * are created when the frame runs out of computed height, but still has
-   * too much content to fit in the availableHeight. The parent creates a
+   * are created when the frame runs out of computed block-size, but still has
+   * too much content to fit in the AvailableBSize. The parent creates a
    * continuation as usual, but marks it as NS_FRAME_IS_OVERFLOW_CONTAINER
    * and adds it to its next-in-flow's overflow container list, either by
    * adding it directly or by putting it in its own excess overflow containers
    * list (to be drained by the next-in-flow when it calls
    * ReflowOverflowContainerChildren). The parent continues reflow as if
-   * the frame was complete once it ran out of computed height, but returns a
-   * reflow status with either IsIncomplete() or IsOverflowIncomplete() equal
+   * the frame was complete once it ran out of computed block-size, but returns
+   * a reflow status with either IsIncomplete() or IsOverflowIncomplete() equal
    * to true to request a next-in-flow. The parent's next-in-flow is then
    * responsible for calling ReflowOverflowContainerChildren to (drain and)
    * reflow these overflow continuations. Overflow containers do not affect
    * other frames' size or position during reflow (but do affect their
    * parent's overflow area).
    *
    * Overflow container continuations are different from normal continuations
    * in that
    *   - more than one child of the frame can have its next-in-flow broken
    *     off and pushed into the frame's next-in-flow
    *   - new continuations may need to be spliced into the middle of the list
    *     or deleted continuations slipped out
    *     e.g. A, B, C are all fixed-size containers on one page, all have
-   *      overflow beyond availableHeight, and content is dynamically added
+   *      overflow beyond AvailableBSize, and content is dynamically added
    *      and removed from B
    * As a result, it is not possible to simply prepend the new continuations
-   * to the old list as with the overflowProperty mechanism. To avoid
+   * to the old list as with the OverflowProperty mechanism. To avoid
    * complicated list splicing, the code assumes only one overflow containers
-   * list exists for a given frame: either its own overflowContainersProperty
-   * or its prev-in-flow's excessOverflowContainersProperty, not both.
+   * list exists for a given frame: either its own OverflowContainersProperty
+   * or its prev-in-flow's ExcessOverflowContainersProperty, not both.
    *
    * The nsOverflowContinuationTracker helper class should be used for tracking
    * overflow containers and adding them to the appropriate list.
    * See nsBlockFrame::Reflow for a sample implementation.
    *
    * For more information, see https://wiki.mozilla.org/Gecko:Continuation_Model
    */