Bug 1598132 - Add GetPrevContinuationOrIBSplitSibling() and improve GetNextContinuationOrIBSplitSibling() in nsLayoutUtils. r=emilio
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 20 Nov 2019 22:31:31 +0000
changeset 503133 561b26f58f176e92de4b75c9e977454514bac413
parent 503132 faea2d543068658ea429302d1e9091f8cf12a613
child 503134 5d2e52a68c0e43dbd5e77e4aca9a387f775f8557
push id101138
push useraethanyc@gmail.com
push dateThu, 21 Nov 2019 02:16:18 +0000
treeherderautoland@561b26f58f17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1598132
milestone72.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 1598132 - Add GetPrevContinuationOrIBSplitSibling() and improve GetNextContinuationOrIBSplitSibling() in nsLayoutUtils. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D54037
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/generic/nsPlaceholderFrame.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4771,26 +4771,41 @@ nsIFrame* nsLayoutUtils::GetParentOrPlac
 
 nsIFrame* nsLayoutUtils::GetDisplayListParent(nsIFrame* aFrame) {
   if (aFrame->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT) {
     return aFrame->GetParent();
   }
   return nsLayoutUtils::GetParentOrPlaceholderForCrossDoc(aFrame);
 }
 
-nsIFrame* nsLayoutUtils::GetNextContinuationOrIBSplitSibling(nsIFrame* aFrame) {
-  nsIFrame* result = aFrame->GetNextContinuation();
-  if (result) return result;
-
-  if ((aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) != 0) {
-    // We only store the ib-split sibling annotation with the first
-    // frame in the continuation chain. Walk back to find that frame now.
-    aFrame = aFrame->FirstContinuation();
-
-    return aFrame->GetProperty(nsIFrame::IBSplitSibling());
+nsIFrame* nsLayoutUtils::GetPrevContinuationOrIBSplitSibling(
+    const nsIFrame* aFrame) {
+  if (nsIFrame* result = aFrame->GetPrevContinuation()) {
+    return result;
+  }
+
+  if (aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) {
+    // We are the first frame in the continuation chain. Get the ib-split prev
+    // sibling property stored in us.
+    return aFrame->GetProperty(nsIFrame::IBSplitPrevSibling());
+  }
+
+  return nullptr;
+}
+
+nsIFrame* nsLayoutUtils::GetNextContinuationOrIBSplitSibling(
+    const nsIFrame* aFrame) {
+  if (nsIFrame* result = aFrame->GetNextContinuation()) {
+    return result;
+  }
+
+  if (aFrame->HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) {
+    // We only store the ib-split sibling annotation with the first frame in the
+    // continuation chain.
+    return aFrame->FirstContinuation()->GetProperty(nsIFrame::IBSplitSibling());
   }
 
   return nullptr;
 }
 
 nsIFrame* nsLayoutUtils::FirstContinuationOrIBSplitSibling(
     const nsIFrame* aFrame) {
   nsIFrame* result = aFrame->FirstContinuation();
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1394,20 +1394,26 @@ class nsLayoutUtils {
    * descending through the frame tree in display list building.
    * Usually the same as GetParentOrPlaceholderForCrossDoc, except
    * that pushed floats are treated as children of their containing
    * block.
    */
   static nsIFrame* GetDisplayListParent(nsIFrame* aFrame);
 
   /**
-   * Get a frame's next-in-flow, or, if it doesn't have one, its
+   * Get a frame's previous continuation, or, if it doesn't have one, its
+   * previous block-in-inline-split sibling.
+   */
+  static nsIFrame* GetPrevContinuationOrIBSplitSibling(const nsIFrame* aFrame);
+
+  /**
+   * Get a frame's next continuation, or, if it doesn't have one, its
    * block-in-inline-split sibling.
    */
-  static nsIFrame* GetNextContinuationOrIBSplitSibling(nsIFrame* aFrame);
+  static nsIFrame* GetNextContinuationOrIBSplitSibling(const nsIFrame* aFrame);
 
   /**
    * Get the first frame in the continuation-plus-ib-split-sibling chain
    * containing aFrame.
    */
   static nsIFrame* FirstContinuationOrIBSplitSibling(const nsIFrame* aFrame);
 
   /**
--- a/layout/generic/nsPlaceholderFrame.cpp
+++ b/layout/generic/nsPlaceholderFrame.cpp
@@ -107,30 +107,26 @@ void nsPlaceholderFrame::Reflow(nsPresCo
   // NOTE that the ReflowInput passed to this method is not fully initialized,
   // on the grounds that reflowing a placeholder is a rather trivial operation.
   // (See bug 1367711.)
 
 #ifdef DEBUG
   // We should be getting reflowed before our out-of-flow.
   // If this is our first reflow, and our out-of-flow has already received its
   // first reflow (before us), complain.
-  // XXXdholbert This "look for a previous continuation or IB-split sibling"
-  // code could use nsLayoutUtils::GetPrevContinuationOrIBSplitSibling(), if
-  // we ever add a function like that. (We currently have a "Next" version.)
   if ((GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
       !(mOutOfFlowFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
     // Unfortunately, this can currently happen when the placeholder is in a
     // later continuation or later IB-split sibling than its out-of-flow (as
     // is the case in some of our existing unit tests). So for now, in that
     // case, we'll warn instead of asserting.
     bool isInContinuationOrIBSplit = false;
     nsIFrame* ancestor = this;
     while ((ancestor = ancestor->GetParent())) {
-      if (ancestor->GetPrevContinuation() ||
-          ancestor->GetProperty(IBSplitPrevSibling())) {
+      if (nsLayoutUtils::GetPrevContinuationOrIBSplitSibling(ancestor)) {
         isInContinuationOrIBSplit = true;
         break;
       }
     }
 
     if (isInContinuationOrIBSplit) {
       NS_WARNING("Out-of-flow frame got reflowed before its placeholder");
     } else {