diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index d3f331548d05..22322ae94447 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -3519,7 +3519,7 @@ ContainerState::NewPaintedLayerData(nsDisplayItem* aItem, data.mAnimatedGeometryRootOffset = aTopLeft; data.mReferenceFrame = aItem->ReferenceFrame(); data.mSingleItemFixedToViewport = aShouldFixToViewport; - data.mBackfaceHidden = aItem->Frame()->BackfaceIsHidden(); + data.mBackfaceHidden = aItem->Frame()->In3DContextAndBackfaceIsHidden(); data.mIsCaret = aItem->GetType() == nsDisplayItem::TYPE_CARET; data.mNewChildLayersIndex = mNewChildLayers.Length(); @@ -4138,7 +4138,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) PaintedLayerData* paintedLayerData = mPaintedLayerDataTree.FindPaintedLayerFor(animatedGeometryRoot, agrScrollClip, itemVisibleRect, false, - item->Frame()->BackfaceIsHidden(), + item->Frame()->In3DContextAndBackfaceIsHidden(), avoidCreatingLayer, [&]() { layerCount++; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index e53ab723b987..98088a84a902 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -1164,6 +1164,12 @@ nsIFrame::Combines3DTransformWithAncestors() const return StyleDisplay()->HasTransform(this) || StyleDisplay()->BackfaceIsHidden(); } +bool +nsIFrame::In3DContextAndBackfaceIsHidden() const +{ + return Combines3DTransformWithAncestors() && StyleDisplay()->BackfaceIsHidden(); +} + bool nsIFrame::HasPerspective() const { diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 65869a5ac1be..29e238710730 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1276,6 +1276,13 @@ public: */ bool Combines3DTransformWithAncestors() const; + /** + * Returns whether this frame has a hidden backface and has a parent that + * Extend3DContext(). This is useful because in some cases the hidden + * backface can safely be ignored if it could not be visible anyway. + */ + bool In3DContextAndBackfaceIsHidden() const; + bool IsPreserve3DLeaf() const { return Combines3DTransformWithAncestors() && !Extend3DContext(); }