diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index bc9852de7259..3847467ca959 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -1301,6 +1301,15 @@ void WebRenderCommandBuilder::DoGroupingForDisplayList( bool snapped; nsRect groupBounds = aWrappingItem->GetBounds(aDisplayListBuilder, &snapped); + // We don't want to restrict the size of the blob to the building rect of the + // display item, since that will change when we scroll and trigger a resize + // invalidation of the blob (will be fixed by blob recoordination). + // Instead we retrieve the bounds of the overflow clip on the and use + // that to restrict our size and prevent invisible content from affecting + // our bounds. + if (mClippedGroupBounds) { + groupBounds = groupBounds.Intersect(mClippedGroupBounds.value()); + } DIGroup& group = groupData->mSubGroup; gfx::Size scale = aSc.GetInheritedScale(); @@ -1485,7 +1494,8 @@ bool WebRenderCommandBuilder::ShouldDumpDisplayList( void WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList( nsDisplayList* aDisplayList, nsDisplayItem* aWrappingItem, nsDisplayListBuilder* aDisplayListBuilder, const StackingContextHelper& aSc, - wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources) { + wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, + nsDisplayItem* aOuterItem) { if (mDoGrouping) { MOZ_RELEASE_ASSERT( aWrappingItem, @@ -1595,6 +1605,25 @@ void WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList( // animated geometry root, so we can combine subsequent items of that // type into the same image. mContainsSVGGroup = mDoGrouping = true; + if (aOuterItem && + aOuterItem->GetType() == DisplayItemType::TYPE_TRANSFORM) { + // Inline should always have an overflow clip, but it gets put + // outside the nsDisplayTransform we create for scaling the svg + // viewport. Converting the clip into inner coordinates lets us + // restrict the size of the blob images and prevents unnecessary + // resizes. + nsDisplayTransform* transform = + static_cast(aOuterItem); + + nsRect clippedBounds = + transform->GetClippedBounds(aDisplayListBuilder); + nsRect innerClippedBounds; + DebugOnly result = transform->UntransformRect( + aDisplayListBuilder, clippedBounds, &innerClippedBounds); + MOZ_ASSERT(result); + + mClippedGroupBounds = Some(innerClippedBounds); + } GP("attempting to enter the grouping code\n"); } diff --git a/gfx/layers/wr/WebRenderCommandBuilder.h b/gfx/layers/wr/WebRenderCommandBuilder.h index 2e3b67c31fe4..e15a26dff8d0 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.h +++ b/gfx/layers/wr/WebRenderCommandBuilder.h @@ -92,10 +92,11 @@ class WebRenderCommandBuilder { nsDisplayListBuilder* aDisplayListBuilder); void CreateWebRenderCommandsFromDisplayList( - nsDisplayList* aDisplayList, nsDisplayItem* aOuterItem, + nsDisplayList* aDisplayList, nsDisplayItem* aWrappingItem, nsDisplayListBuilder* aDisplayListBuilder, const StackingContextHelper& aSc, wr::DisplayListBuilder& aBuilder, - wr::IpcResourceUpdateQueue& aResources); + wr::IpcResourceUpdateQueue& aResources, + nsDisplayItem* aOuterItem = nullptr); // aWrappingItem has to be non-null. void DoGroupingForDisplayList(nsDisplayList* aDisplayList, @@ -201,6 +202,7 @@ class WebRenderCommandBuilder { // Whether consecutive inactive display items should be grouped into one // blob image. bool mDoGrouping; + Maybe mClippedGroupBounds; // True if we're currently within an opacity:0 container, and only // plugin and hit test items should be considered. diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index ca41d4a4c9ec..759904ef566d 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -7893,8 +7893,10 @@ bool nsDisplayTransform::CreateWebRenderCommands( params, LayoutDeviceRect(position, LayoutDeviceSize())); - return mStoredList.CreateWebRenderCommands(aBuilder, aResources, sc, aManager, - aDisplayListBuilder); + aManager->CommandBuilder().CreateWebRenderCommandsFromDisplayList( + mStoredList.GetChildren(), &mStoredList, aDisplayListBuilder, sc, + aBuilder, aResources, this); + return true; } bool nsDisplayTransform::UpdateScrollData(