From eed10147054b5b7280d0263b224efe7433bab017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 4 Oct 2018 20:24:04 +0000 Subject: [PATCH] Bug 1495169 - Remove cached measuring reflows if we aren't measuring the right thing because we got interrupted. r=dholbert 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 --HG-- extra : moz-landing-system : lando --- layout/generic/nsFlexContainerFrame.cpp | 18 ++++++++++++++++++ layout/generic/nsFlexContainerFrame.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index b04512948696..7fcda8fd4da0 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -4324,6 +4324,24 @@ FlexLine::PositionItemsInCrossAxis(nscoord aLineStartPosition, } } +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, diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h index cf4dffd16297..34edf84b1a6e 100644 --- a/layout/generic/nsFlexContainerFrame.h +++ b/layout/generic/nsFlexContainerFrame.h @@ -125,6 +125,8 @@ public: const ReflowInput& aReflowInput, nsReflowStatus& aStatus) override; + void DidReflow(nsPresContext*, const ReflowInput*) final; + nscoord GetMinISize(gfxContext* aRenderingContext) override; nscoord GetPrefISize(gfxContext* aRenderingContext) override;