Bug 1715369. Handle the case of a StackingContextHelper inside a deferred transform item with a different asr. r=mstange

Whenever the asr of the deferred transform item differs from the current asr and we are about to enter a new StackingContextHelper (as opposed to just when we enter a transformed frame) flush the deferred transform item, so it's transform doesn't get lost.

This is similar to https://phabricator.services.mozilla.com/D8111. In fact we are extending https://phabricator.services.mozilla.com/D8111 to every time we enter a StackingContextHelper. https://phabricator.services.mozilla.com/D8111 was concerned with solving the case of having two nested transform items with different asrs and making sure we don't lose the outer transform item, here we need to solve the case of an outer transformed item and an inner StackingContextHelper (which is not for a transform) with a different asr and making sure we don't lose the outer transform item.

Note that some of the items I added CreatesStackingContextHelper return true don't always make a new StackingContextHelper. It seemed better to be consistent and I think the only downside is a little less perf because we have to create a few more scrolldata nodes.

Differential Revision: https://phabricator.services.mozilla.com/D118815
This commit is contained in:
Timothy Nikkel 2021-07-08 23:07:11 +00:00
Родитель 0ace0ca0d9
Коммит 0d00be970f
3 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -31,6 +31,8 @@ StackingContextHelper::StackingContextHelper(
mDeferredTransformItem(aParams.mDeferredTransformItem),
mRasterizeLocally(aParams.mRasterizeLocally ||
aParentSC.mRasterizeLocally) {
MOZ_ASSERT(!aContainerItem || aContainerItem->CreatesStackingContextHelper());
mOrigin = aParentSC.mOrigin + aBounds.TopLeft();
// Compute scale for fallback rendering. We don't try to guess a scale for 3d
// transformed items

Просмотреть файл

@ -1750,8 +1750,7 @@ void WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(
// merge the deferred transforms, but need to force a new
// WebRenderLayerScrollData item to flush the old deferred transform, so
// that we can then start deferring the new one.
if (!forceNewLayerData &&
item->GetType() == DisplayItemType::TYPE_TRANSFORM &&
if (!forceNewLayerData && item->CreatesStackingContextHelper() &&
aSc.GetDeferredTransformItem() &&
(*aSc.GetDeferredTransformItem())->GetActiveScrolledRoot() != asr) {
forceNewLayerData = true;

Просмотреть файл

@ -2398,6 +2398,8 @@ class nsDisplayItemBase : public nsDisplayItemLink {
return false;
}
virtual bool CreatesStackingContextHelper() { return false; }
protected:
nsDisplayItemBase(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
: mFrame(aFrame), mType(DisplayItemType::TYPE_ZERO) {
@ -5648,6 +5650,8 @@ class nsDisplayOpacity : public nsDisplayWrapList {
float GetOpacity() const { return mOpacity; }
bool CreatesStackingContextHelper() override { return true; }
private:
NS_DISPLAY_ALLOW_CLONING()
@ -5728,6 +5732,8 @@ class nsDisplayBlendMode : public nsDisplayWrapList {
mozilla::gfx::CompositionOp BlendMode();
bool CreatesStackingContextHelper() override { return true; }
protected:
mozilla::StyleBlend mBlendMode;
bool mIsForBackground;
@ -5827,6 +5833,8 @@ class nsDisplayBlendContainer : public nsDisplayWrapList {
return false;
}
bool CreatesStackingContextHelper() override { return true; }
protected:
nsDisplayBlendContainer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList,
@ -5993,6 +6001,8 @@ class nsDisplayOwnLayer : public nsDisplayWrapList {
bool IsStickyPositionLayer() const;
bool HasDynamicToolbar() const;
bool CreatesStackingContextHelper() override { return true; }
protected:
nsDisplayOwnLayerFlags mFlags;
@ -6113,6 +6123,8 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
const ActiveScrolledRoot* GetContainerASR() const { return mContainerASR; }
bool CreatesStackingContextHelper() override { return true; }
private:
NS_DISPLAY_ALLOW_CLONING()
@ -6552,6 +6564,8 @@ class nsDisplayMasksAndClipPaths : public nsDisplayEffectsBase {
nsDisplayListBuilder* aBuilder,
const ActiveScrolledRoot* aASR) const override;
bool CreatesStackingContextHelper() override { return true; }
private:
NS_DISPLAY_ALLOW_CLONING()
@ -6594,6 +6608,8 @@ class nsDisplayBackdropRootContainer : public nsDisplayWrapList {
bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override {
return !aBuilder->IsPaintingForWebRender();
}
bool CreatesStackingContextHelper() override { return true; }
};
class nsDisplayBackdropFilters : public nsDisplayWrapList {
@ -6624,6 +6640,8 @@ class nsDisplayBackdropFilters : public nsDisplayWrapList {
return !aBuilder->IsPaintingForWebRender();
}
bool CreatesStackingContextHelper() override { return true; }
private:
nsRect mBackdropRect;
};
@ -6710,6 +6728,8 @@ class nsDisplayFilters : public nsDisplayEffectsBase {
nsDisplayListBuilder* aDisplayListBuilder) override;
bool CanCreateWebRenderCommands();
bool CreatesStackingContextHelper() override { return true; }
private:
NS_DISPLAY_ALLOW_CLONING()
@ -7072,6 +7092,8 @@ class nsDisplayTransform : public nsPaintedDisplayItem {
void AddSizeOfExcludingThis(nsWindowSizes&) const override;
bool CreatesStackingContextHelper() override { return true; }
private:
void ComputeBounds(nsDisplayListBuilder* aBuilder);
nsRect TransformUntransformedBounds(nsDisplayListBuilder* aBuilder,
@ -7194,6 +7216,8 @@ class nsDisplayPerspective : public nsPaintedDisplayItem {
}
}
bool CreatesStackingContextHelper() override { return true; }
private:
mutable RetainedDisplayList mList;
};