Bug 979782: Fixup FindFrameForContentSibling to don't duplicate work and trigger assertions for display: contents. r=mats
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 01 Nov 2017 16:40:09 +0100
changeset 440361 8012fdbac3eb1f2f03f8605c7b49751be8c8de60
parent 440360 7c7118016cc8aaaa61dd7138134c65e30929d7f4
child 440362 86abda160c8a121a036aa144c4ccd7fde9776725
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs979782
milestone58.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 979782: Fixup FindFrameForContentSibling to don't duplicate work and trigger assertions for display: contents. r=mats MozReview-Commit-ID: HAZh0RYY76x
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -6883,16 +6883,22 @@ nsCSSFrameConstructor::FindFrameForConte
                            : nsLayoutUtils::GetBeforeFrame(aContent);
     if (!sibling) {
       // ... then recurse into children ...
       const bool forward = !aPrevSibling;
       FlattenedChildIterator iter(aContent, forward);
       sibling = aPrevSibling ?
         FindPreviousSibling(iter, aTargetContent, aTargetContentDisplay, aParentFrame) :
         FindNextSibling(iter, aTargetContent, aTargetContentDisplay, aParentFrame);
+
+      // The recursion above has already done all the placeholder and
+      // continuation fixups.
+      if (sibling) {
+        return sibling;
+      }
     }
     if (!sibling) {
       // ... then ::after / ::before on the opposite end.
       sibling = aPrevSibling ? nsLayoutUtils::GetAfterFrame(aContent)
                              : nsLayoutUtils::GetBeforeFrame(aContent);
     }
     if (!sibling) {
       return nullptr;
@@ -6906,17 +6912,17 @@ nsCSSFrameConstructor::FindFrameForConte
   // If the frame is out-of-flow, GetPrimaryFrame() will have returned the
   // out-of-flow frame; we want the placeholder.
   if (sibling->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
     nsIFrame* placeholderFrame = sibling->GetPlaceholderFrame();
     NS_ASSERTION(placeholderFrame, "no placeholder for out-of-flow frame");
     sibling = placeholderFrame;
   }
 
-  // The frame we have now should never be a continuation
+  // The frame we have now should never be a continuation.
   NS_ASSERTION(!sibling->GetPrevContinuation(), "How did that happen?");
 
   if (aPrevSibling) {
     // The frame may be a ib-split frame (a split inline frame that
     // contains a block).  Get the last part of that split.
     if (IsFramePartOfIBSplit(sibling)) {
       sibling = GetLastIBSplitSibling(sibling, true);
     }