diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index ef7ae71a7a9..ba97f154d6d 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -1527,8 +1527,10 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, } else #endif - /* If there is any opacity, wrap it up in an opacity list. */ - if (disp->mOpacity < 1.0f) { + /* If there is any opacity, wrap it up in an opacity list. + * If there's nothing in the list, don't add anything. + */ + if (disp->mOpacity < 1.0f && !resultList.IsEmpty()) { rv = resultList.AppendNewToTop( new (aBuilder) nsDisplayOpacity(aBuilder, this, &resultList)); if (NS_FAILED(rv)) @@ -1536,10 +1538,10 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, } /* If we're going to apply a transformation, wrap everything in an - * nsDisplayTransform. + * nsDisplayTransform. If there's nothing in the list, don't add anything. */ if ((mState & NS_FRAME_MAY_BE_TRANSFORMED) && - disp->HasTransform()) { + disp->HasTransform() && !resultList.IsEmpty()) { rv = resultList.AppendNewToTop( new (aBuilder) nsDisplayTransform(aBuilder, this, &resultList)); if (NS_FAILED(rv))