Bug 1411860 - Create nsDisplaySubDocument unconditionally. r=mattwoodrow
MozReview-Commit-ID: ELXI1SYZTa4
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -571,23 +571,23 @@ nsSubDocumentFrame::BuildDisplayList(nsD
}
if (constructResolutionItem) {
nsDisplayResolution* resolutionItem =
new (aBuilder) nsDisplayResolution(aBuilder, subdocRootFrame, &childItems,
flags);
childItems.AppendToTop(resolutionItem);
needsOwnLayer = false;
}
- if (needsOwnLayer) {
- // We always want top level content documents to be in their own layer.
- nsDisplaySubDocument* layerItem = new (aBuilder) nsDisplaySubDocument(
- aBuilder, subdocRootFrame ? subdocRootFrame : this, this,
- &childItems, flags);
- childItems.AppendToTop(layerItem);
- }
+
+ // We always want top level content documents to be in their own layer.
+ nsDisplaySubDocument* layerItem = new (aBuilder) nsDisplaySubDocument(
+ aBuilder, subdocRootFrame ? subdocRootFrame : this, this,
+ &childItems, flags);
+ childItems.AppendToTop(layerItem);
+ layerItem->SetShouldFlattenAway(!needsOwnLayer);
// If we're using containers for root frames, then the earlier call
// to AddCanvasBackgroundColorItem won't have been able to add an
// unscrolled color item for overscroll. Try again now that we're
// outside the scrolled ContainerLayer.
if (!aBuilder->IsForEventDelivery() &&
gfxPrefs::LayoutUseContainersForRootFrames() &&
!nsLayoutUtils::NeedsPrintPreviewBackground(presContext)) {
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6838,16 +6838,17 @@ nsDisplayOwnLayer::UpdateScrollData(mozi
}
nsDisplaySubDocument::nsDisplaySubDocument(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
nsSubDocumentFrame* aSubDocFrame,
nsDisplayList* aList, uint32_t aFlags)
: nsDisplayOwnLayer(aBuilder, aFrame, aList, aBuilder->CurrentActiveScrolledRoot(), aFlags)
, mScrollParentId(aBuilder->GetCurrentScrollParentId())
+ , mShouldFlatten(false)
, mSubDocFrame(aSubDocFrame)
{
MOZ_COUNT_CTOR(nsDisplaySubDocument);
mForceDispatchToContentRegion =
aBuilder->IsBuildingLayerEventRegions() &&
nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(aFrame->PresContext()->PresShell());
// The SubDocument display item is conceptually outside the viewport frame,
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -5091,27 +5091,38 @@ public:
virtual nsSubDocumentFrame* SubDocumentFrame() { return mSubDocFrame; }
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion) override;
virtual bool ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder) const override;
+ virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override
+ {
+ return mShouldFlatten;
+ }
+
+ void SetShouldFlattenAway(bool aShouldFlatten)
+ {
+ mShouldFlatten = aShouldFlatten;
+ }
+
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap) const override;
NS_DISPLAY_DECL_NAME("SubDocument", TYPE_SUBDOCUMENT)
mozilla::UniquePtr<ScrollMetadata> ComputeScrollMetadata(Layer* aLayer,
const ContainerLayerParameters& aContainerParameters);
protected:
ViewID mScrollParentId;
bool mForceDispatchToContentRegion;
+ bool mShouldFlatten;
nsSubDocumentFrame* mSubDocFrame;
};
/**
* A display item for subdocuments to capture the resolution from the presShell
* and ensure that it gets applied to all the right elements. This item creates
* a container layer.
*/