Bug 1495169 - Remove cached measuring reflows if we aren't measuring the right thing because we got interrupted. r=dholbert, a=pascalc
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 04 Oct 2018 20:24:04 +0000
changeset 490274 9f144c575382
parent 490273 491779804da9
child 490275 119b1911d0da
push id9971
push userryanvm@gmail.com
push dateThu, 11 Oct 2018 19:46:56 +0000
treeherdermozilla-beta@94ae3c41f785 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, pascalc
bugs1495169, 1209697, 1495532
milestone63.0
Bug 1495169 - Remove cached measuring reflows if we aren't measuring the right thing because we got interrupted. r=dholbert, a=pascalc If we're waiting on an interrupt, then our child items haven't been totally reflowed and our measures would be bogus. This will probably regress performance in the cases bug 1209697 fixed, so we should probably add an interrupt check somewhere in nsFlexContainerFrame to avoid keeping reflowing flex containers indefinitely. We could probably just bail out from our reflow if any kid reflow was interrupted. Filed bug 1495532 to consider that. Differential Revision: https://phabricator.services.mozilla.com/D7288
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsFlexContainerFrame.h
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -4297,16 +4297,34 @@ FlexLine::PositionItemsInCrossAxis(nscoo
                            lineCrossAxisPosnTracker.GetPosition());
 
     // Back out to cross-axis edge of the line.
     lineCrossAxisPosnTracker.ResetPosition();
   }
 }
 
 void
+nsFlexContainerFrame::DidReflow(nsPresContext* aPresContext,
+                                const ReflowInput* aReflowInput)
+{
+  // Remove the cached values if we got an interrupt because the values will be
+  // the wrong ones for following reflows.
+  //
+  // TODO(emilio): Can we do this only for the kids that are interrupted? We
+  // probably want to figure out what the right thing to do here is regarding
+  // interrupts, see bug 1495532.
+  if (aPresContext->HasPendingInterrupt()) {
+    for (nsIFrame* frame : mFrames) {
+      frame->DeleteProperty(CachedFlexMeasuringReflow());
+    }
+  }
+  nsContainerFrame::DidReflow(aPresContext, aReflowInput);
+}
+
+void
 nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
                              ReflowOutput& aDesiredSize,
                              const ReflowInput& aReflowInput,
                              nsReflowStatus& aStatus)
 {
   MarkInReflow();
   DO_GLOBAL_REFLOW_COUNT("nsFlexContainerFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
--- a/layout/generic/nsFlexContainerFrame.h
+++ b/layout/generic/nsFlexContainerFrame.h
@@ -118,16 +118,18 @@ public:
 
   void MarkIntrinsicISizesDirty() override;
 
   void Reflow(nsPresContext* aPresContext,
               ReflowOutput& aDesiredSize,
               const ReflowInput& aReflowInput,
               nsReflowStatus& aStatus) override;
 
+  void DidReflow(nsPresContext*, const ReflowInput*) final;
+
   nscoord GetMinISize(gfxContext* aRenderingContext) override;
   nscoord GetPrefISize(gfxContext* aRenderingContext) override;
 
 #ifdef DEBUG_FRAME_DUMP
   nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
   nscoord GetLogicalBaseline(mozilla::WritingMode aWM) const override;