From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- layout/painting/crashtests/1862277-1.html | 6 +-- layout/painting/crashtests/1870415-1.html | 35 +++++++++++++++++ layout/painting/crashtests/crashtests.list | 7 ++-- layout/painting/nsDisplayList.cpp | 63 +++++++++++++++--------------- layout/painting/nsDisplayList.h | 27 +++++++++++-- 5 files changed, 95 insertions(+), 43 deletions(-) create mode 100644 layout/painting/crashtests/1870415-1.html (limited to 'layout/painting') diff --git a/layout/painting/crashtests/1862277-1.html b/layout/painting/crashtests/1862277-1.html index 820bade2fd..f732bb71b6 100644 --- a/layout/painting/crashtests/1862277-1.html +++ b/layout/painting/crashtests/1862277-1.html @@ -15,11 +15,7 @@ that is affected by the clip path a couple times. The retained display list won' container, but the modified display list will have the nsDisplayMask, this will confuse merging when the same item appears inside two different containers. -Note that we set widget.windows.window_occlusion_tracking.enabled=false for this test because -crashtests leave windows open and occlud the crashtest window, which means the refresh driver doesn't -run, which means the requestAnimationFrame don't run. Bug 1864255 tracks fixing this. - -Note that we image.decode-sync.enabled=false for this test because sync decoding triggers extra +Note that we image.testing.decode-sync.enabled=false for this test because sync decoding triggers extra invalidation which "fixes" this bug before it gets a chance to appear. Bug 1866411 tracks this. --> diff --git a/layout/painting/crashtests/1870415-1.html b/layout/painting/crashtests/1870415-1.html new file mode 100644 index 0000000000..ef379dad4d --- /dev/null +++ b/layout/painting/crashtests/1870415-1.html @@ -0,0 +1,35 @@ + + + + + + diff --git a/layout/painting/crashtests/crashtests.list b/layout/painting/crashtests/crashtests.list index 954e2de6e2..b51fa60007 100644 --- a/layout/painting/crashtests/crashtests.list +++ b/layout/painting/crashtests/crashtests.list @@ -8,7 +8,7 @@ load 1418722-1.html load 1419917.html load 1425271-1.html load 1428906-1.html -pref(widget.windows.window_occlusion_tracking.enabled,false) load 1430589-1.html # Bug 1819154 +load 1430589-1.html load 1454105-1.html load 1455944-1.html load 1458145.html @@ -18,7 +18,7 @@ load 1469472.html load 1477831-1.html load 1504033.html load 1514544-1.html -asserts(0-5) load 1547420-1.html +asserts(0-10) load 1547420-1.html # bug 1524064 load 1549909.html load 1551389-1.html asserts(0-2) load 1555819-1.html @@ -31,4 +31,5 @@ load 1714584-1.html load 1763006-1.html load 1819957-1.html load 1851726-1.html -pref(widget.windows.window_occlusion_tracking.enabled,false) pref(image.decode-sync.enabled,false) load 1862277-1.html +pref(image.testing.decode-sync.enabled,false) load 1862277-1.html +needs-focus pref(ui.caretBlinkTime,200) pref(image.testing.decode-sync.enabled,false) asserts(0-2) load 1870415-1.html diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 2c2b7cb04c..0007f86c5e 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -5207,7 +5207,7 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands( Maybe prop; bool needsProp = aManager->LayerManager()->AsyncPanZoomEnabled() && (IsScrollThumbLayer() || IsZoomingLayer() || - ShouldGetFixedOrStickyAnimationId() || + ShouldGetFixedAnimationId() || (IsRootScrollbarContainer() && HasDynamicToolbar())); if (needsProp) { @@ -5234,7 +5234,7 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands( params.prim_flags |= wr::PrimitiveFlags::IS_SCROLLBAR_CONTAINER; } if (IsZoomingLayer() || - (ShouldGetFixedOrStickyAnimationId() || + (ShouldGetFixedAnimationId() || (IsRootScrollbarContainer() && HasDynamicToolbar()))) { params.is_2d_scale_translation = true; params.should_snap = true; @@ -5250,9 +5250,8 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands( bool nsDisplayOwnLayer::UpdateScrollData(WebRenderScrollData* aData, WebRenderLayerScrollData* aLayerData) { - bool isRelevantToApz = - (IsScrollThumbLayer() || IsScrollbarContainer() || IsZoomingLayer() || - ShouldGetFixedOrStickyAnimationId()); + bool isRelevantToApz = (IsScrollThumbLayer() || IsScrollbarContainer() || + IsZoomingLayer() || ShouldGetFixedAnimationId()); if (!isRelevantToApz) { return false; @@ -5267,16 +5266,11 @@ bool nsDisplayOwnLayer::UpdateScrollData(WebRenderScrollData* aData, return true; } - if (IsFixedPositionLayer() && ShouldGetFixedOrStickyAnimationId()) { + if (IsFixedPositionLayer() && ShouldGetFixedAnimationId()) { aLayerData->SetFixedPositionAnimationId(mWrAnimationId); return true; } - if (IsStickyPositionLayer() && ShouldGetFixedOrStickyAnimationId()) { - aLayerData->SetStickyPositionAnimationId(mWrAnimationId); - return true; - } - MOZ_ASSERT(IsScrollbarContainer() || IsScrollThumbLayer()); aLayerData->SetScrollbarData(mScrollbarData); @@ -5458,7 +5452,7 @@ bool nsDisplayFixedPosition::UpdateScrollData( return true; } -bool nsDisplayFixedPosition::ShouldGetFixedOrStickyAnimationId() { +bool nsDisplayFixedPosition::ShouldGetFixedAnimationId() { #if defined(MOZ_WIDGET_ANDROID) return mFrame->PresContext()->IsRootContentDocumentCrossProcess() && nsLayoutUtils::ScrollIdForRootScrollFrame(mFrame->PresContext()) == @@ -5522,7 +5516,8 @@ nsDisplayStickyPosition::nsDisplayStickyPosition( : nsDisplayOwnLayer(aBuilder, aFrame, aList, aActiveScrolledRoot), mContainerASR(aContainerASR), mClippedToDisplayPort(aClippedToDisplayPort), - mShouldFlatten(false) { + mShouldFlatten(false), + mWrStickyAnimationId(0) { MOZ_COUNT_CTOR(nsDisplayStickyPosition); } @@ -5738,12 +5733,27 @@ bool nsDisplayStickyPosition::CreateWebRenderCommands( wr::LayoutVector2D applied = { NSAppUnitsToFloatPixels(appliedOffset.x, auPerDevPixel), NSAppUnitsToFloatPixels(appliedOffset.y, auPerDevPixel)}; + bool needsProp = ShouldGetStickyAnimationId(); + Maybe prop; + auto spatialKey = wr::SpatialKey(uint64_t(mFrame), GetPerFrameKey(), + wr::SpatialKeyKind::Sticky); + if (needsProp) { + RefPtr animationData = + aManager->CommandBuilder() + .CreateOrRecycleWebRenderUserData( + this); + mWrStickyAnimationId = animationData->GetAnimationId(); + + prop.emplace(); + prop->id = mWrStickyAnimationId; + prop->key = spatialKey; + prop->effect_type = wr::WrAnimationType::Transform; + } wr::WrSpatialId spatialId = aBuilder.DefineStickyFrame( wr::ToLayoutRect(bounds), topMargin.ptrOr(nullptr), rightMargin.ptrOr(nullptr), bottomMargin.ptrOr(nullptr), - leftMargin.ptrOr(nullptr), vBounds, hBounds, applied, - wr::SpatialKey(uint64_t(mFrame), GetPerFrameKey(), - wr::SpatialKeyKind::Sticky)); + leftMargin.ptrOr(nullptr), vBounds, hBounds, applied, spatialKey, + prop.ptrOr(nullptr)); saccHelper.emplace(aBuilder, spatialId); aManager->CommandBuilder().PushOverrideForASR(mContainerASR, spatialId); @@ -5812,6 +5822,10 @@ bool nsDisplayStickyPosition::UpdateScrollData( ->GetContent()); aLayerData->SetStickyPositionScrollContainerId(scrollId); } + + if (ShouldGetStickyAnimationId()) { + aLayerData->SetStickyPositionAnimationId(mWrStickyAnimationId); + } } // Return true if either there is a dynamic toolbar affecting this sticky // item or the OwnLayer base implementation returns true for some other @@ -5821,21 +5835,8 @@ bool nsDisplayStickyPosition::UpdateScrollData( return ret; } -bool nsDisplayStickyPosition::ShouldGetFixedOrStickyAnimationId() { -#if defined(MOZ_WIDGET_ANDROID) - if (HasDynamicToolbar()) { // also implies being in the cross-process RCD - StickyScrollContainer* stickyScrollContainer = GetStickyScrollContainer(); - if (stickyScrollContainer) { - ScrollableLayerGuid::ViewID scrollId = - nsLayoutUtils::FindOrCreateIDFor(stickyScrollContainer->ScrollFrame() - ->GetScrolledFrame() - ->GetContent()); - return nsLayoutUtils::ScrollIdForRootScrollFrame(mFrame->PresContext()) == - scrollId; - } - } -#endif - return false; +bool nsDisplayStickyPosition::ShouldGetStickyAnimationId() const { + return HasDynamicToolbar(); // also implies being in the cross-process RCD } nsDisplayScrollInfoLayer::nsDisplayScrollInfoLayer( diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index acda6ea863..9862415f61 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -5475,7 +5475,7 @@ class nsDisplayOwnLayer : public nsDisplayWrapList { bool IsFixedPositionLayer() const; bool IsStickyPositionLayer() const; bool HasDynamicToolbar() const; - virtual bool ShouldGetFixedOrStickyAnimationId() { return false; } + virtual bool ShouldGetFixedAnimationId() { return false; } bool CreatesStackingContextHelper() override { return true; } @@ -5491,6 +5491,16 @@ class nsDisplayOwnLayer : public nsDisplayWrapList { */ layers::ScrollbarData mScrollbarData; bool mForceActive; + + // Used for APZ to animate this layer for purposes such as + // pinch-zooming or scrollbar thumb movement. Note that setting this + // creates a WebRender ReferenceFrame spatial node, and should only + // be used for display items that establish a Gecko reference frame + // as well (or leaf items like scrollbar thumb nodes where it does not + // matter). + // FIXME: This is currently also used for adjusting position:fixed items + // for dynamic toolbar movement. This may be a problem as position:fixed + // items do not establish Gecko reference frames. uint64_t mWrAnimationId; }; @@ -5550,7 +5560,8 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer { : nsDisplayOwnLayer(aBuilder, aOther), mContainerASR(aOther.mContainerASR), mClippedToDisplayPort(aOther.mClippedToDisplayPort), - mShouldFlatten(false) { + mShouldFlatten(false), + mWrStickyAnimationId(0) { MOZ_COUNT_CTOR(nsDisplayStickyPosition); } @@ -5575,7 +5586,6 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer { bool UpdateScrollData(layers::WebRenderScrollData* aData, layers::WebRenderLayerScrollData* aLayerData) override; - bool ShouldGetFixedOrStickyAnimationId() override; const ActiveScrolledRoot* GetContainerASR() const { return mContainerASR; } @@ -5591,6 +5601,8 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer { return mShouldFlatten; } + bool ShouldGetStickyAnimationId() const; + private: NS_DISPLAY_ALLOW_CLONING() @@ -5620,6 +5632,13 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer { // True if this item should be flattened away. bool mShouldFlatten; + + // Used for APZ to animate the sticky element in the compositor + // for purposes such as dynamic toolbar movement and (in the future) + // overscroll-related adjustment. Unlike nsDisplayOwnLayer::mWrAnimationId, + // this does not create a WebRender ReferenceFrame, which is important + // because sticky elements do not establish Gecko reference frames either. + uint64_t mWrStickyAnimationId; }; class nsDisplayFixedPosition : public nsDisplayOwnLayer { @@ -5661,7 +5680,7 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer { nsDisplayListBuilder* aDisplayListBuilder) override; bool UpdateScrollData(layers::WebRenderScrollData* aData, layers::WebRenderLayerScrollData* aLayerData) override; - bool ShouldGetFixedOrStickyAnimationId() override; + bool ShouldGetFixedAnimationId() override; void WriteDebugInfo(std::stringstream& aStream) override; protected: -- cgit v1.2.3