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 492905 9f144c575382a05e93c5c39e5186711588d98a0e
parent 492904 491779804da9cc041b85f0d78fff3df322f994e9
child 492906 119b1911d0da671e5e381c925ee44d5d325575c2
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [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;