Bug 1365356 - patch 2 - Allow callers to pass an nsStyleDisplay in to FinishAndStoreOverflow, to avoid internal StyleDisplay() calls. r=mats

This commit is contained in:
Jonathan Kew 2017-05-17 15:47:31 +01:00
parent 97a920ea30
commit 6d345e8ee2
7 changed files with 47 additions and 33 deletions

View File

@ -7112,7 +7112,8 @@ nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame)
{
nsIFrame *f = aFrame;
for (;;) {
if (f->IsTransformed() || f->IsPreserve3DLeaf() || IsPopup(f)) {
const nsStyleDisplay* disp = f->StyleDisplay();
if (f->IsTransformed(disp) || f->IsPreserve3DLeaf(disp) || IsPopup(f)) {
return f;
}
nsIFrame* parent = GetCrossDocParentFrame(f);

View File

@ -1453,7 +1453,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
}
}
FinishAndStoreOverflow(&aMetrics);
FinishAndStoreOverflow(&aMetrics, reflowInput->mStyleDisplay);
aStatus = state.mReflowStatus;

View File

@ -216,7 +216,7 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
LogicalSize convertedSize = kidMetrics.Size(lineWM).ConvertTo(wm, lineWM);
kid->SetRect(nsRect(bp.IStart(wm), bp.BStart(wm),
convertedSize.ISize(wm), convertedSize.BSize(wm)));
kid->FinishAndStoreOverflow(&kidMetrics);
kid->FinishAndStoreOverflow(&kidMetrics, rs.mStyleDisplay);
kid->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
convertedSize.ISize(wm) += bp.IStartEnd(wm);
@ -232,7 +232,7 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
aMetrics.UnionOverflowAreasWithDesiredBounds();
ConsiderChildOverflow(aMetrics.mOverflowAreas, kid);
FinishAndStoreOverflow(&aMetrics);
FinishAndStoreOverflow(&aMetrics, aReflowInput.mStyleDisplay);
} else {
// Pretend we are a span and reflow the child frame
nsLineLayout* ll = aReflowInput.mLineLayout;

View File

@ -1341,9 +1341,9 @@ nsIFrame::IsSVGTransformed(gfx::Matrix *aOwnTransforms,
}
bool
nsIFrame::Extend3DContext() const
nsIFrame::Extend3DContext(const nsStyleDisplay* aStyleDisplay) const
{
const nsStyleDisplay* disp = StyleDisplay();
const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
if (disp->mTransformStyle != NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D ||
!IsFrameOfType(nsIFrame::eSupportsCSSTransforms)) {
return false;
@ -1370,7 +1370,8 @@ nsIFrame::Combines3DTransformWithAncestors(const nsStyleDisplay* aStyleDisplay)
if (!GetParent() || !GetParent()->Extend3DContext()) {
return false;
}
return IsTransformed(aStyleDisplay) || BackfaceIsHidden(aStyleDisplay);
const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
return IsTransformed(disp) || BackfaceIsHidden(disp);
}
bool
@ -1383,9 +1384,10 @@ nsIFrame::In3DContextAndBackfaceIsHidden() const
}
bool
nsIFrame::HasPerspective() const
nsIFrame::HasPerspective(const nsStyleDisplay* aStyleDisplay) const
{
if (!IsTransformed()) {
const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
if (!IsTransformed(disp)) {
return false;
}
nsIFrame* containingBlock = GetContainingBlock(SKIP_SCROLLED_FRAME);
@ -1396,9 +1398,10 @@ nsIFrame::HasPerspective() const
}
bool
nsIFrame::ChildrenHavePerspective() const
nsIFrame::ChildrenHavePerspective(const nsStyleDisplay* aStyleDisplay) const
{
return StyleDisplay()->HasPerspectiveStyle();
const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
return disp->HasPerspectiveStyle();
}
nsRect
@ -2375,9 +2378,9 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
aBuilder->AddToWillChangeBudget(this, GetSize());
}
bool extend3DContext = Extend3DContext();
bool extend3DContext = Extend3DContext(disp);
Maybe<nsDisplayListBuilder::AutoPreserves3DContext> autoPreserves3DContext;
if (extend3DContext && !Combines3DTransformWithAncestors()) {
if (extend3DContext && !Combines3DTransformWithAncestors(disp)) {
// Start a new preserves3d context to keep informations on
// nsDisplayListBuilder.
autoPreserves3DContext.emplace(aBuilder);
@ -2421,7 +2424,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
// If we're in preserve-3d then grab the dirty rect that was given to the root
// and transform using the combined transform.
if (Combines3DTransformWithAncestors()) {
if (Combines3DTransformWithAncestors(disp)) {
dirtyRect = aBuilder->GetPreserves3DDirtyRect(this);
}
@ -5889,7 +5892,7 @@ nsFrame::FinishReflowWithAbsoluteFrames(nsPresContext* aPresContext,
{
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowInput, aStatus, aConstrainBSize);
FinishAndStoreOverflow(&aDesiredSize);
FinishAndStoreOverflow(&aDesiredSize, aReflowInput.mStyleDisplay);
}
void
@ -8955,12 +8958,13 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas,
bool
nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
nsSize aNewSize, nsSize* aOldSize)
nsSize aNewSize, nsSize* aOldSize,
const nsStyleDisplay* aStyleDisplay)
{
MOZ_ASSERT(FrameMaintainsOverflow(),
"Don't call - overflow rects not maintained on these SVG frames");
const nsStyleDisplay* disp = StyleDisplay();
const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
bool hasTransform = IsTransformed(disp);
nsRect bounds(nsPoint(0, 0), aNewSize);
@ -9072,7 +9076,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
*/
SetSize(aNewSize);
if (ChildrenHavePerspective() && sizeChanged) {
if (ChildrenHavePerspective(disp) && sizeChanged) {
nsRect newBounds(nsPoint(0, 0), aNewSize);
RecomputePerspectiveChildrenOverflow(this);
}
@ -9081,7 +9085,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
Properties().Set(nsIFrame::PreTransformOverflowAreasProperty(),
new nsOverflowAreas(aOverflowAreas));
if (Combines3DTransformWithAncestors()) {
if (Combines3DTransformWithAncestors(disp)) {
/* If we're a preserve-3d leaf frame, then our pre-transform overflow should be correct. Our
* post-transform overflow is empty though, because we only contribute to the overflow area
* of the preserve-3d root frame.
@ -9099,7 +9103,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
* the participants. This won't have happened yet as the code above set their overflow
* area to empty. Manually collect these overflow areas now.
*/
if (Extend3DContext()) {
if (Extend3DContext(disp)) {
ComputePreserve3DChildrenOverflow(aOverflowAreas);
}
}
@ -9177,7 +9181,8 @@ nsIFrame::ComputePreserve3DChildrenOverflow(nsOverflowAreas& aOverflowAreas)
// If this child participates in the 3d context, then take the pre-transform
// region (which contains all descendants that aren't participating in the 3d context)
// and transform it into the 3d context root coordinate space.
if (child->Combines3DTransformWithAncestors()) {
const nsStyleDisplay* childDisp = child->StyleDisplay();
if (child->Combines3DTransformWithAncestors(childDisp)) {
nsOverflowAreas childOverflow = child->GetOverflowAreasRelativeToSelf();
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
@ -9189,7 +9194,7 @@ nsIFrame::ComputePreserve3DChildrenOverflow(nsOverflowAreas& aOverflowAreas)
// If this child also extends the 3d context, then recurse into it
// looking for more participants.
if (child->Extend3DContext()) {
if (child->Extend3DContext(childDisp)) {
child->ComputePreserve3DChildrenOverflow(aOverflowAreas);
}
}

View File

@ -1718,8 +1718,11 @@ public:
* Returns whether this frame will attempt to extend the 3d transforms of its
* children. This requires transform-style: preserve-3d, as well as no clipping
* or svg effects.
*
* @param aStyleDisplay: If the caller has this->StyleDisplay(), providing
* it here will improve performance.
*/
bool Extend3DContext() const;
bool Extend3DContext(const nsStyleDisplay* aStyleDisplay = nullptr) const;
/**
* Returns whether this frame has a parent that Extend3DContext() and has
@ -1739,13 +1742,15 @@ public:
*/
bool In3DContextAndBackfaceIsHidden() const;
bool IsPreserve3DLeaf() const {
return Combines3DTransformWithAncestors() && !Extend3DContext();
bool IsPreserve3DLeaf(const nsStyleDisplay* aStyleDisplay = nullptr) const {
const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
return Combines3DTransformWithAncestors(disp) &&
!Extend3DContext(disp);
}
bool HasPerspective() const;
bool HasPerspective(const nsStyleDisplay* aStyleDisplay = nullptr) const;
bool ChildrenHavePerspective() const;
bool ChildrenHavePerspective(const nsStyleDisplay* aStyleDisplay = nullptr) const;
/**
* Includes the overflow area of all descendants that participate in the current
@ -3027,11 +3032,14 @@ public:
* the overflow areas changed.
*/
bool FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
nsSize aNewSize, nsSize* aOldSize = nullptr);
nsSize aNewSize, nsSize* aOldSize = nullptr,
const nsStyleDisplay* aStyleDisplay = nullptr);
bool FinishAndStoreOverflow(ReflowOutput* aMetrics) {
bool FinishAndStoreOverflow(ReflowOutput* aMetrics,
const nsStyleDisplay* aStyleDisplay = nullptr) {
return FinishAndStoreOverflow(aMetrics->mOverflowAreas,
nsSize(aMetrics->Width(), aMetrics->Height()));
nsSize(aMetrics->Width(), aMetrics->Height()),
nullptr, aStyleDisplay);
}
/**

View File

@ -1048,7 +1048,7 @@ nsImageFrame::Reflow(nsPresContext* aPresContext,
// to request a decode.
MaybeDecodeForPredictedSize();
}
FinishAndStoreOverflow(&aMetrics);
FinishAndStoreOverflow(&aMetrics, aReflowInput.mStyleDisplay);
if ((GetStateBits() & NS_FRAME_FIRST_REFLOW) && !mReflowCallbackPosted) {
nsIPresShell* shell = PresContext()->PresShell();

View File

@ -64,7 +64,7 @@ nsLeafFrame::Reflow(nsPresContext* aPresContext,
DoReflow(aPresContext, aMetrics, aReflowInput, aStatus);
FinishAndStoreOverflow(&aMetrics);
FinishAndStoreOverflow(&aMetrics, aReflowInput.mStyleDisplay);
}
void
@ -111,5 +111,5 @@ nsLeafFrame::SizeToAvailSize(const ReflowInput& aReflowInput,
aReflowInput.AvailableBSize());
aDesiredSize.SetSize(wm, size);
aDesiredSize.SetOverflowAreasToDesiredBounds();
FinishAndStoreOverflow(&aDesiredSize);
FinishAndStoreOverflow(&aDesiredSize, aReflowInput.mStyleDisplay);
}