Bug 1367711 - Bail out early when initializing ReflowInput for a placeholder frame, which has a trivial Reflow method. r=mats
authorJonathan Kew <jkew@mozilla.com>
Tue, 30 May 2017 23:55:02 +0100
changeset 409578 e4ac809a2e76161c335b9a8dbac2a4a243f33952
parent 409577 07fe4661db8f181e17ae1cc33e92c7e106947d89
child 409579 7b82e5e570d6e28138167115fe74a2d5d32c9e07
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1367711
milestone55.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 1367711 - Bail out early when initializing ReflowInput for a placeholder frame, which has a trivial Reflow method. r=mats
layout/generic/ReflowInput.cpp
layout/generic/nsPlaceholderFrame.cpp
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -386,16 +386,22 @@ ReflowInput::Init(nsPresContext*     aPr
   mStyleDisplay = mFrame->StyleDisplay();
   mStyleVisibility = mFrame->StyleVisibility();
   mStyleBorder = mFrame->StyleBorder();
   mStyleMargin = mFrame->StyleMargin();
   mStylePadding = mFrame->StylePadding();
   mStyleText = mFrame->StyleText();
 
   LayoutFrameType type = mFrame->Type();
+  if (type == mozilla::LayoutFrameType::Placeholder) {
+    // Placeholders have a no-op Reflow method that doesn't need the rest of
+    // this initialization, so we bail out early.
+    ComputedBSize() = ComputedISize() = 0;
+    return;
+  }
 
   InitFrameType(type);
   InitCBReflowInput();
 
   LogicalSize cbSize(mWritingMode, -1, -1);
   if (aContainingBlockSize) {
     cbSize = *aContainingBlockSize;
   }
--- a/layout/generic/nsPlaceholderFrame.cpp
+++ b/layout/generic/nsPlaceholderFrame.cpp
@@ -105,16 +105,20 @@ nsPlaceholderFrame::AddInlinePrefISize(n
 }
 
 void
 nsPlaceholderFrame::Reflow(nsPresContext*           aPresContext,
                            ReflowOutput&     aDesiredSize,
                            const ReflowInput& aReflowInput,
                            nsReflowStatus&          aStatus)
 {
+  // 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) &&