Bug 1728251 - Remove mClip and compute it when we need it. r=miko

Differential Revision: https://phabricator.services.mozilla.com/D124008
This commit is contained in:
Matt Woodrow 2021-09-06 23:12:04 +00:00
Родитель e7b3614318
Коммит 51b371636c
2 изменённых файлов: 12 добавлений и 25 удалений

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

@ -2771,8 +2771,7 @@ nsDisplayItem::nsDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
aBuilder->GetVisibleRect().width >= 0 || !aBuilder->IsForPainting(), aBuilder->GetVisibleRect().width >= 0 || !aBuilder->IsForPainting(),
"visible rect not set"); "visible rect not set");
nsDisplayItem::SetClipChain( mClipChain = aBuilder->ClipState().GetCurrentCombinedClipChain(aBuilder);
aBuilder->ClipState().GetCurrentCombinedClipChain(aBuilder), true);
// The visible rect is for mCurrentFrame, so we have to use // The visible rect is for mCurrentFrame, so we have to use
// mCurrentOffsetToReferenceFrame // mCurrentOffsetToReferenceFrame
@ -2809,7 +2808,6 @@ int32_t nsDisplayItem::ZIndex() const { return mFrame->ZIndex().valueOr(0); }
void nsDisplayItem::SetClipChain(const DisplayItemClipChain* aClipChain, void nsDisplayItem::SetClipChain(const DisplayItemClipChain* aClipChain,
bool aStore) { bool aStore) {
mClipChain = aClipChain; mClipChain = aClipChain;
mClip = DisplayItemClipChain::ClipForASR(aClipChain, mActiveScrolledRoot);
} }
Maybe<nsRect> nsDisplayItem::GetClipWithRespectToASR( Maybe<nsRect> nsDisplayItem::GetClipWithRespectToASR(
@ -2824,6 +2822,12 @@ Maybe<nsRect> nsDisplayItem::GetClipWithRespectToASR(
return Nothing(); return Nothing();
} }
const DisplayItemClip& nsDisplayItem::GetClip() const {
const DisplayItemClip* clip =
DisplayItemClipChain::ClipForASR(mClipChain, mActiveScrolledRoot);
return clip ? *clip : DisplayItemClip::NoClip();
}
void nsDisplayItem::IntersectClip(nsDisplayListBuilder* aBuilder, void nsDisplayItem::IntersectClip(nsDisplayListBuilder* aBuilder,
const DisplayItemClipChain* aOther, const DisplayItemClipChain* aOther,
bool aStore) { bool aStore) {
@ -5819,20 +5823,6 @@ nsDisplayStickyPosition::nsDisplayStickyPosition(
MOZ_COUNT_CTOR(nsDisplayStickyPosition); MOZ_COUNT_CTOR(nsDisplayStickyPosition);
} }
void nsDisplayStickyPosition::SetClipChain(
const DisplayItemClipChain* aClipChain, bool aStore) {
mClipChain = aClipChain;
mClip = nullptr;
MOZ_ASSERT(!mClip,
"There should never be a clip on this item because no clip moves "
"with it.");
if (aStore) {
mOriginalClipChain = aClipChain;
}
}
// Returns the smallest distance from "0" to the range [min, max] where // Returns the smallest distance from "0" to the range [min, max] where
// min <= max. Despite the name, the return value is actually a 1-D vector, // min <= max. Despite the name, the return value is actually a 1-D vector,
// and so may be negative if max < 0. // and so may be negative if max < 0.

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

@ -2387,8 +2387,7 @@ class nsDisplayItem : public nsDisplayItemLink {
mToReferenceFrame(aOther.mToReferenceFrame), mToReferenceFrame(aOther.mToReferenceFrame),
mAnimatedGeometryRoot(aOther.mAnimatedGeometryRoot), mAnimatedGeometryRoot(aOther.mAnimatedGeometryRoot),
mActiveScrolledRoot(aOther.mActiveScrolledRoot), mActiveScrolledRoot(aOther.mActiveScrolledRoot),
mClipChain(aOther.mClipChain), mClipChain(aOther.mClipChain) {
mClip(aOther.mClip) {
MOZ_COUNT_CTOR(nsDisplayItem); MOZ_COUNT_CTOR(nsDisplayItem);
// TODO: It might be better to remove the flags that aren't copied. // TODO: It might be better to remove the flags that aren't copied.
if (aOther.ForceNotVisible()) { if (aOther.ForceNotVisible()) {
@ -2841,9 +2840,7 @@ class nsDisplayItem : public nsDisplayItemLink {
virtual bool SupportsOptimizingToImage() const { return false; } virtual bool SupportsOptimizingToImage() const { return false; }
const DisplayItemClip& GetClip() const { virtual const DisplayItemClip& GetClip() const;
return mClip ? *mClip : DisplayItemClip::NoClip();
}
void IntersectClip(nsDisplayListBuilder* aBuilder, void IntersectClip(nsDisplayListBuilder* aBuilder,
const DisplayItemClipChain* aOther, bool aStore); const DisplayItemClipChain* aOther, bool aStore);
@ -2962,7 +2959,6 @@ class nsDisplayItem : public nsDisplayItemLink {
RefPtr<AnimatedGeometryRoot> mAnimatedGeometryRoot; RefPtr<AnimatedGeometryRoot> mAnimatedGeometryRoot;
RefPtr<const ActiveScrolledRoot> mActiveScrolledRoot; RefPtr<const ActiveScrolledRoot> mActiveScrolledRoot;
RefPtr<const DisplayItemClipChain> mClipChain; RefPtr<const DisplayItemClipChain> mClipChain;
const DisplayItemClip* mClip = nullptr;
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
public: public:
@ -5609,8 +5605,9 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayStickyPosition) MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayStickyPosition)
void SetClipChain(const DisplayItemClipChain* aClipChain, const DisplayItemClip& GetClip() const override {
bool aStore) override; return DisplayItemClip::NoClip();
}
bool IsClippedToDisplayPort() const { return mClippedToDisplayPort; } bool IsClippedToDisplayPort() const { return mClippedToDisplayPort; }
NS_DISPLAY_DECL_NAME("StickyPosition", TYPE_STICKY_POSITION) NS_DISPLAY_DECL_NAME("StickyPosition", TYPE_STICKY_POSITION)