Bug 1779602 - Remove nsImageGeometryMixin. r=tnikkel

nsImageGeometryMixin was disabled in bug 1776198. No problems have shown up
so let's get rid of it.

Differential Revision: https://phabricator.services.mozilla.com/D151864
This commit is contained in:
Jeff Muizelaar 2022-07-18 21:20:50 +00:00
Родитель c973d7e4a7
Коммит 5cbce534c4
19 изменённых файлов: 24 добавлений и 478 удалений

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

@ -354,11 +354,6 @@ class nsDisplayButtonBorder final : public nsPaintedDisplayItem {
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) const override;
virtual nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override;
virtual void ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
virtual bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@ -370,11 +365,6 @@ class nsDisplayButtonBorder final : public nsPaintedDisplayItem {
nsButtonFrameRenderer* mBFR;
};
nsDisplayItemGeometry* nsDisplayButtonBorder::AllocateGeometry(
nsDisplayListBuilder* aBuilder) {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
bool nsDisplayButtonBorder::CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@ -410,21 +400,6 @@ bool nsDisplayButtonBorder::CreateWebRenderCommands(
return true;
}
void nsDisplayButtonBorder::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
void nsDisplayButtonBorder::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
NS_ASSERTION(mFrame, "No frame?");
@ -432,10 +407,8 @@ void nsDisplayButtonBorder::Paint(nsDisplayListBuilder* aBuilder,
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
// draw the border and background inside the focus and outline borders
ImgDrawResult result =
mBFR->PaintBorder(aBuilder, pc, *aCtx, GetPaintRect(aBuilder, aCtx), r);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
Unused << mBFR->PaintBorder(aBuilder, pc, *aCtx, GetPaintRect(aBuilder, aCtx),
r);
}
nsRect nsDisplayButtonBorder::GetBounds(nsDisplayListBuilder* aBuilder,
@ -455,11 +428,6 @@ class nsDisplayButtonForeground final : public nsPaintedDisplayItem {
}
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayButtonForeground)
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override;
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
@ -472,35 +440,13 @@ class nsDisplayButtonForeground final : public nsPaintedDisplayItem {
nsButtonFrameRenderer* mBFR;
};
nsDisplayItemGeometry* nsDisplayButtonForeground::AllocateGeometry(
nsDisplayListBuilder* aBuilder) {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void nsDisplayButtonForeground::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
// Draw the -moz-focus-inner border
ImgDrawResult result = mBFR->PaintInnerFocusBorder(
aBuilder, mFrame->PresContext(), *aCtx, GetPaintRect(aBuilder, aCtx), r);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
Unused << mBFR->PaintInnerFocusBorder(aBuilder, mFrame->PresContext(), *aCtx,
GetPaintRect(aBuilder, aCtx), r);
}
bool nsDisplayButtonForeground::CreateWebRenderCommands(

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

@ -109,11 +109,6 @@ class nsDisplayFieldSetBorder final : public nsPaintedDisplayItem {
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayFieldSetBorder)
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
virtual nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override;
virtual void ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
bool CreateWebRenderCommands(
mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
@ -127,30 +122,8 @@ class nsDisplayFieldSetBorder final : public nsPaintedDisplayItem {
void nsDisplayFieldSetBorder::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) {
ImgDrawResult result = static_cast<nsFieldSetFrame*>(mFrame)->PaintBorder(
Unused << static_cast<nsFieldSetFrame*>(mFrame)->PaintBorder(
aBuilder, *aCtx, ToReferenceFrame(), GetPaintRect(aBuilder, aCtx));
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
nsDisplayItemGeometry* nsDisplayFieldSetBorder::AllocateGeometry(
nsDisplayListBuilder* aBuilder) {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void nsDisplayFieldSetBorder::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
nsRect nsDisplayFieldSetBorder::GetBounds(nsDisplayListBuilder* aBuilder,
@ -217,8 +190,6 @@ bool nsDisplayFieldSetBorder::CreateWebRenderCommands(
if (drawResult == ImgDrawResult::NOT_SUPPORTED) {
return false;
}
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, drawResult);
return true;
};

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

@ -108,11 +108,6 @@ class nsDisplayGradient final : public nsPaintedDisplayItem {
}
~nsDisplayGradient() final { MOZ_COUNT_DTOR(nsDisplayGradient); }
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) final {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
nsRect GetBounds(bool* aSnap) const {
*aSnap = true;
return Frame()->GetContentRectRelativeToSelf() + ToReferenceFrame();
@ -150,7 +145,7 @@ void nsDisplayGradient::Paint(nsDisplayListBuilder* aBuilder,
frame->PresContext(), *aCtx, dest, dest, dest.TopLeft(),
GetPaintRect(aBuilder, aCtx), dest.Size(), /* aOpacity = */ 1.0f);
}
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
Unused << result;
}
bool nsDisplayGradient::CreateWebRenderCommands(
@ -177,7 +172,6 @@ bool nsDisplayGradient::CreateWebRenderCommands(
return false;
}
}
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
return true;
}
@ -1547,27 +1541,6 @@ class nsDisplayAltFeedback final : public nsPaintedDisplayItem {
nsDisplayAltFeedback(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
: nsPaintedDisplayItem(aBuilder, aFrame) {}
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) final {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const final {
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry,
aInvalidRegion);
}
nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const final {
*aSnap = false;
return mFrame->InkOverflowRectRelativeToSelf() + ToReferenceFrame();
@ -1579,10 +1552,8 @@ class nsDisplayAltFeedback final : public nsPaintedDisplayItem {
uint32_t flags = imgIContainer::FLAG_SYNC_DECODE;
nsImageFrame* f = static_cast<nsImageFrame*>(mFrame);
ImgDrawResult result = f->DisplayAltFeedback(
*aCtx, GetPaintRect(aBuilder, aCtx), ToReferenceFrame(), flags);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
Unused << f->DisplayAltFeedback(*aCtx, GetPaintRect(aBuilder, aCtx),
ToReferenceFrame(), flags);
}
bool CreateWebRenderCommands(
@ -2058,29 +2029,6 @@ void nsDisplayImage::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
GetPaintRect(aBuilder, aCtx), mPrevImage, flags);
}
}
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
nsDisplayItemGeometry* nsDisplayImage::AllocateGeometry(
nsDisplayListBuilder* aBuilder) {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void nsDisplayImage::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsPaintedDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry,
aInvalidRegion);
}
nsRect nsDisplayImage::GetDestRect() const {
@ -2207,8 +2155,6 @@ bool nsDisplayImage::CreateWebRenderCommands(
// help us. Hence we can ignore the return value from PushImage.
aManager->CommandBuilder().PushImageProvider(
this, provider, drawResult, aBuilder, aResources, destRect, destRect);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, drawResult);
return true;
}

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

@ -472,10 +472,6 @@ class nsDisplayImage final : public nsPaintedDisplayItem {
}
~nsDisplayImage() final { MOZ_COUNT_DTOR(nsDisplayImage); }
nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder*) final;
void ComputeInvalidationRegion(nsDisplayListBuilder*,
const nsDisplayItemGeometry*,
nsRegion* aInvalidRegion) const final;
void Paint(nsDisplayListBuilder*, gfxContext* aCtx) final;
/**

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

@ -264,27 +264,6 @@ class nsDisplaymtdBorder final : public nsDisplayBorder {
nsDisplaymtdBorder(nsDisplayListBuilder* aBuilder, nsMathMLmtdFrame* aFrame)
: nsDisplayBorder(aBuilder, aFrame) {}
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override {
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry,
aInvalidRegion);
}
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) const override {
*aSnap = true;
@ -311,11 +290,9 @@ class nsDisplaymtdBorder final : public nsDisplayBorder {
? PaintBorderFlags::SyncDecodeImages
: PaintBorderFlags();
ImgDrawResult result = nsCSSRendering::PaintBorderWithStyleBorder(
Unused << nsCSSRendering::PaintBorderWithStyleBorder(
mFrame->PresContext(), *aCtx, mFrame, GetPaintRect(aBuilder, aCtx),
bounds, styleBorder, mFrame->Style(), flags, mFrame->GetSkipSides());
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
bool CreateWebRenderCommands(

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

@ -3427,8 +3427,6 @@ bool nsDisplayBackgroundImage::CreateWebRenderCommands(
if (result == ImgDrawResult::NOT_SUPPORTED) {
return false;
}
nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
return true;
}
@ -3564,13 +3562,11 @@ void nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder,
aBuilder->GetBackgroundPaintFlags(), mLayer, CompositionOp::OP_OVER,
1.0f);
params.bgClipRect = aClipRect;
ImgDrawResult result = nsCSSRendering::PaintStyleImageLayer(params, *aCtx);
Unused << nsCSSRendering::PaintStyleImageLayer(params, *aCtx);
if (clip == StyleGeometryBox::Text) {
ctx->PopGroupAndBlend();
}
nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
}
void nsDisplayBackgroundImage::ComputeInvalidationRegion(
@ -3600,14 +3596,6 @@ void nsDisplayBackgroundImage::ComputeInvalidationRegion(
aInvalidRegion->Or(bounds, geometry->mBounds);
return;
}
if (aBuilder->ShouldSyncDecodeImages()) {
const auto& image =
mBackgroundStyle->StyleBackground()->mImage.mLayers[mLayer].mImage;
if (image.IsImageRequestType() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
aInvalidRegion->Or(*aInvalidRegion, bounds);
}
}
if (!bounds.IsEqualInterior(geometry->mBounds)) {
// Positioning area is unchanged, so invalidate just the change in the
// painting area.
@ -4239,11 +4227,6 @@ void nsDisplayBorder::ComputeInvalidationRegion(
// is apparently painting a background with this?
aInvalidRegion->Or(GetBounds(aBuilder, &snap), geometry->mBounds);
}
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
}
bool nsDisplayBorder::CreateWebRenderCommands(
@ -4259,8 +4242,6 @@ bool nsDisplayBorder::CreateWebRenderCommands(
if (drawResult == ImgDrawResult::NOT_SUPPORTED) {
return false;
}
nsDisplayBorderGeometry::UpdateDrawResult(this, drawResult);
return true;
};
@ -4271,12 +4252,10 @@ void nsDisplayBorder::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
? PaintBorderFlags::SyncDecodeImages
: PaintBorderFlags();
ImgDrawResult result = nsCSSRendering::PaintBorder(
Unused << nsCSSRendering::PaintBorder(
mFrame->PresContext(), *aCtx, mFrame, GetPaintRect(aBuilder, aCtx),
nsRect(offset, mFrame->GetSize()), mFrame->Style(), flags,
mFrame->GetSkipSides());
nsDisplayBorderGeometry::UpdateDrawResult(this, result);
}
nsRect nsDisplayBorder::GetBounds(nsDisplayListBuilder* aBuilder,
@ -7944,8 +7923,6 @@ bool nsDisplayMasksAndClipPaths::PaintMask(nsDisplayListBuilder* aBuilder,
*aMaskPainted = painted;
}
nsDisplayMasksAndClipPathsGeometry::UpdateDrawResult(this, imgParams.result);
return maskIsComplete &&
(imgParams.result == ImgDrawResult::SUCCESS ||
imgParams.result == ImgDrawResult::SUCCESS_NOT_COMPLETE ||
@ -7973,18 +7950,6 @@ void nsDisplayMasksAndClipPaths::ComputeInvalidationRegion(
}
}
}
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
const nsStyleSVGReset* svgReset = mFrame->StyleSVGReset();
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, svgReset->mMask) {
const auto& image = svgReset->mMask.mLayers[i].mImage;
if (image.IsImageRequestType()) {
aInvalidRegion->Or(*aInvalidRegion, bounds);
break;
}
}
}
}
void nsDisplayMasksAndClipPaths::PaintWithContentsPaintCallback(
@ -8009,8 +7974,6 @@ void nsDisplayMasksAndClipPaths::PaintWithContentsPaintCallback(
SVGIntegrationUtils::PaintMaskAndClipPath(params, aPaintChildren);
context->PopClip();
nsDisplayMasksAndClipPathsGeometry::UpdateDrawResult(this, imgParams.result);
}
void nsDisplayMasksAndClipPaths::Paint(nsDisplayListBuilder* aBuilder,
@ -8370,22 +8333,6 @@ void nsDisplayFilters::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
});
}
void nsDisplayFilters::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
nsDisplayEffectsBase::ComputeInvalidationRegion(aBuilder, aGeometry,
aInvalidRegion);
const auto* geometry =
static_cast<const nsDisplayFiltersGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
nsRect bounds = GetBounds(aBuilder, &snap);
aInvalidRegion->Or(*aInvalidRegion, bounds);
}
}
void nsDisplayFilters::PaintWithContentsPaintCallback(
nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
const std::function<void(gfxContext* aContext)>& aPaintChildren) {
@ -8408,7 +8355,6 @@ void nsDisplayFilters::PaintWithContentsPaintCallback(
-userSpaceToFrameSpaceOffset));
aPaintChildren(&aContext);
});
nsDisplayFiltersGeometry::UpdateDrawResult(this, imgParams.result);
}
bool nsDisplayFilters::CanCreateWebRenderCommands() const {

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

@ -6067,12 +6067,9 @@ class nsDisplayFilters : public nsDisplayEffectsBase {
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override {
return new nsDisplayFiltersGeometry(this, aBuilder);
return new nsDisplaySVGEffectGeometry(this, aBuilder);
}
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
#ifdef MOZ_DUMP_PAINTING
void PrintEffects(nsACString& aTo);
#endif

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

@ -54,13 +54,11 @@ nsDisplayItemBoundsGeometry::nsDisplayItemBoundsGeometry(
nsDisplayBorderGeometry::nsDisplayBorderGeometry(nsDisplayItem* aItem,
nsDisplayListBuilder* aBuilder)
: nsDisplayItemGeometry(aItem, aBuilder),
nsImageGeometryMixin(aItem, aBuilder) {}
: nsDisplayItemGeometry(aItem, aBuilder) {}
nsDisplayBackgroundGeometry::nsDisplayBackgroundGeometry(
nsDisplayBackgroundImage* aItem, nsDisplayListBuilder* aBuilder)
: nsDisplayItemGeometry(aItem, aBuilder),
nsImageGeometryMixin(aItem, aBuilder),
mPositioningArea(aItem->GetPositioningArea()),
mDestRect(aItem->GetDestRect()) {}
@ -111,19 +109,16 @@ void nsDisplaySVGEffectGeometry::MoveBy(const nsPoint& aOffset) {
nsDisplayMasksAndClipPathsGeometry::nsDisplayMasksAndClipPathsGeometry(
nsDisplayMasksAndClipPaths* aItem, nsDisplayListBuilder* aBuilder)
: nsDisplaySVGEffectGeometry(aItem, aBuilder),
nsImageGeometryMixin(aItem, aBuilder),
mDestRects(aItem->GetDestRects().Clone()) {}
nsDisplayFiltersGeometry::nsDisplayFiltersGeometry(
nsDisplayFilters* aItem, nsDisplayListBuilder* aBuilder)
: nsDisplaySVGEffectGeometry(aItem, aBuilder),
nsImageGeometryMixin(aItem, aBuilder) {}
: nsDisplaySVGEffectGeometry(aItem, aBuilder) {}
nsDisplayTableItemGeometry::nsDisplayTableItemGeometry(
nsDisplayTableItem* aItem, nsDisplayListBuilder* aBuilder,
const nsPoint& aFrameOffsetToViewport)
: nsDisplayItemGenericGeometry(aItem, aBuilder),
nsImageGeometryMixin(aItem, aBuilder),
mFrameOffsetToViewport(aFrameOffsetToViewport) {}
} // namespace mozilla

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

@ -58,8 +58,6 @@ class nsDisplayItemGeometry {
*/
virtual void MoveBy(const nsPoint& aOffset) { mBounds.MoveBy(aOffset); }
virtual bool InvalidateForSyncDecodeImages() const { return false; }
/**
* Bounds of the display item
*/
@ -86,90 +84,6 @@ bool ShouldSyncDecodeImages(nsDisplayListBuilder* aBuilder);
nsDisplayItemGeometry* GetPreviousGeometry(nsDisplayItem*);
/**
* nsImageGeometryMixin is a mixin for geometry items that draw images.
* Geometry items that include this mixin can track drawing results and use
* that information to inform invalidation decisions.
*
* This mixin uses CRTP; its template parameter should be the type of the class
* that is inheriting from it. See nsDisplayItemGenericImageGeometry for an
* example.
*/
template <typename T>
class nsImageGeometryMixin {
public:
nsImageGeometryMixin(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
: mLastDrawResult(mozilla::image::ImgDrawResult::NOT_READY),
mWaitingForPaint(false) {
// Transfer state from the previous version of this geometry item.
if (auto lastGeometry = static_cast<T*>(GetPreviousGeometry(aItem))) {
mLastDrawResult = lastGeometry->mLastDrawResult;
mWaitingForPaint = lastGeometry->mWaitingForPaint;
}
// If our display item is going to invalidate to trigger sync decoding of
// images, mark ourselves as waiting for a paint. If we actually get
// painted, UpdateDrawResult will get called, and we'll clear the flag.
if (ShouldSyncDecodeImages(aBuilder) &&
ShouldInvalidateToSyncDecodeImages()) {
mWaitingForPaint = true;
}
}
static void UpdateDrawResult(nsDisplayItem* aItem,
mozilla::image::ImgDrawResult aResult) {
MOZ_ASSERT(aResult != mozilla::image::ImgDrawResult::NOT_SUPPORTED,
"ImgDrawResult::NOT_SUPPORTED should be handled already!");
if (auto lastGeometry = static_cast<T*>(GetPreviousGeometry(aItem))) {
lastGeometry->mLastDrawResult = aResult;
lastGeometry->mWaitingForPaint = false;
}
}
bool ShouldInvalidateToSyncDecodeImages() const {
if (mWaitingForPaint) {
// We previously invalidated for sync decoding and haven't gotten painted
// since them. This suggests that our display item is completely occluded
// and there's no point in invalidating again - and because the reftest
// harness takes a new snapshot every time we invalidate, doing so might
// lead to an invalidation loop if we're in a reftest.
return false;
}
if (mLastDrawResult == mozilla::image::ImgDrawResult::SUCCESS ||
mLastDrawResult == mozilla::image::ImgDrawResult::BAD_IMAGE) {
return false;
}
return false;
}
private:
mozilla::image::ImgDrawResult mLastDrawResult;
bool mWaitingForPaint;
};
/**
* nsDisplayItemGenericImageGeometry is a generic geometry item class that
* includes nsImageGeometryMixin.
*
* This should be sufficient for most display items that draw images.
*/
class nsDisplayItemGenericImageGeometry
: public nsDisplayItemGenericGeometry,
public nsImageGeometryMixin<nsDisplayItemGenericImageGeometry> {
public:
nsDisplayItemGenericImageGeometry(nsDisplayItem* aItem,
nsDisplayListBuilder* aBuilder)
: nsDisplayItemGenericGeometry(aItem, aBuilder),
nsImageGeometryMixin(aItem, aBuilder) {}
bool InvalidateForSyncDecodeImages() const override {
return ShouldInvalidateToSyncDecodeImages();
}
};
class nsDisplayItemBoundsGeometry : public nsDisplayItemGeometry {
public:
nsDisplayItemBoundsGeometry(nsDisplayItem* aItem,
@ -178,30 +92,18 @@ class nsDisplayItemBoundsGeometry : public nsDisplayItemGeometry {
bool mHasRoundedCorners;
};
class nsDisplayBorderGeometry
: public nsDisplayItemGeometry,
public nsImageGeometryMixin<nsDisplayBorderGeometry> {
class nsDisplayBorderGeometry : public nsDisplayItemGeometry {
public:
nsDisplayBorderGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
bool InvalidateForSyncDecodeImages() const override {
return ShouldInvalidateToSyncDecodeImages();
}
};
class nsDisplayBackgroundGeometry
: public nsDisplayItemGeometry,
public nsImageGeometryMixin<nsDisplayBackgroundGeometry> {
class nsDisplayBackgroundGeometry : public nsDisplayItemGeometry {
public:
nsDisplayBackgroundGeometry(nsDisplayBackgroundImage* aItem,
nsDisplayListBuilder* aBuilder);
void MoveBy(const nsPoint& aOffset) override;
bool InvalidateForSyncDecodeImages() const override {
return ShouldInvalidateToSyncDecodeImages();
}
nsRect mPositioningArea;
nsRect mDestRect;
};
@ -217,21 +119,14 @@ class nsDisplayThemedBackgroundGeometry : public nsDisplayItemGeometry {
bool mWindowIsActive;
};
class nsDisplayTreeBodyGeometry
: public nsDisplayItemGenericGeometry,
public nsImageGeometryMixin<nsDisplayTreeBodyGeometry> {
class nsDisplayTreeBodyGeometry : public nsDisplayItemGenericGeometry {
public:
nsDisplayTreeBodyGeometry(nsDisplayItem* aItem,
nsDisplayListBuilder* aBuilder,
bool aWindowIsActive)
: nsDisplayItemGenericGeometry(aItem, aBuilder),
nsImageGeometryMixin(aItem, aBuilder),
mWindowIsActive(aWindowIsActive) {}
bool InvalidateForSyncDecodeImages() const override {
return ShouldInvalidateToSyncDecodeImages();
}
bool mWindowIsActive = false;
};
@ -283,44 +178,26 @@ class nsDisplaySVGEffectGeometry : public nsDisplayItemGeometry {
bool mHandleOpacity;
};
class nsDisplayMasksAndClipPathsGeometry
: public nsDisplaySVGEffectGeometry,
public nsImageGeometryMixin<nsDisplayMasksAndClipPathsGeometry> {
class nsDisplayMasksAndClipPathsGeometry : public nsDisplaySVGEffectGeometry {
public:
nsDisplayMasksAndClipPathsGeometry(nsDisplayMasksAndClipPaths* aItem,
nsDisplayListBuilder* aBuilder);
bool InvalidateForSyncDecodeImages() const override {
return ShouldInvalidateToSyncDecodeImages();
}
nsTArray<nsRect> mDestRects;
};
class nsDisplayFiltersGeometry
: public nsDisplaySVGEffectGeometry,
public nsImageGeometryMixin<nsDisplayFiltersGeometry> {
class nsDisplayFiltersGeometry : public nsDisplaySVGEffectGeometry {
public:
nsDisplayFiltersGeometry(nsDisplayFilters* aItem,
nsDisplayListBuilder* aBuilder);
bool InvalidateForSyncDecodeImages() const override {
return ShouldInvalidateToSyncDecodeImages();
}
};
class nsDisplayTableItemGeometry
: public nsDisplayItemGenericGeometry,
public nsImageGeometryMixin<nsDisplayTableItemGeometry> {
class nsDisplayTableItemGeometry : public nsDisplayItemGenericGeometry {
public:
nsDisplayTableItemGeometry(nsDisplayTableItem* aItem,
nsDisplayListBuilder* aBuilder,
const nsPoint& aFrameOffsetToViewport);
bool InvalidateForSyncDecodeImages() const override {
return ShouldInvalidateToSyncDecodeImages();
}
nsPoint mFrameOffsetToViewport;
};

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

@ -86,24 +86,6 @@ void DisplaySVGGeometry::Paint(nsDisplayListBuilder* aBuilder,
gfxMatrix::Translation(devPixelOffset);
imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags());
static_cast<SVGGeometryFrame*>(mFrame)->PaintSVG(*aCtx, tm, imgParams);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, imgParams.result);
}
void DisplaySVGGeometry::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
const auto* geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsPaintedDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry,
aInvalidRegion);
}
//----------------------------------------------------------------------

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

@ -166,15 +166,6 @@ class DisplaySVGGeometry final : public nsPaintedDisplayItem {
nsTArray<nsIFrame*>* aOutFrames) override;
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
// Whether this part of the SVG should be natively handled by webrender,
// potentially becoming an "active layer" inside a blob image.
bool ShouldBeActive(mozilla::wr::DisplayListBuilder& aBuilder,

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

@ -656,8 +656,6 @@ bool SVGImageFrame::CreateWebRenderCommands(
aBuilder, aResources,
destRect, clipRect);
}
nsDisplayItemGenericImageGeometry::UpdateDrawResult(aItem, drawResult);
}
return true;

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

@ -557,11 +557,6 @@ class nsDisplayOuterSVG final : public nsPaintedDisplayItem {
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
NS_DISPLAY_DECL_NAME("SVGOuterSVG", TYPE_SVG_OUTER_SVG)
};
@ -626,7 +621,6 @@ void nsDisplayOuterSVG::Paint(nsDisplayListBuilder* aBuilder,
gfxMatrix::Translation(devPixelOffset);
SVGUtils::PaintFrameWithEffects(mFrame, *aContext, tm, imgParams,
&contentAreaDirtyRect);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, imgParams.result);
aContext->Restore();
#if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)
@ -658,15 +652,6 @@ void nsDisplayOuterSVG::ComputeInvalidationRegion(
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
aInvalidRegion->Or(*aInvalidRegion, result);
const auto* geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
}
nsresult SVGOuterSVGFrame::AttributeChanged(int32_t aNameSpaceID,

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

@ -2703,7 +2703,7 @@ class DisplaySVGText final : public nsPaintedDisplayItem {
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
return new nsDisplayItemGenericGeometry(this, aBuilder);
}
virtual nsRect GetComponentAlphaBounds(
@ -2749,7 +2749,6 @@ void DisplaySVGText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
gfxContext* ctx = aCtx;
imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags());
static_cast<SVGTextFrame*>(mFrame)->PaintSVG(*ctx, tm, imgParams);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, imgParams.result);
}
// ---------------------------------------------------------------------

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

@ -7498,26 +7498,6 @@ nsRect nsDisplayTableItem::GetBounds(nsDisplayListBuilder* aBuilder,
return mFrame->InkOverflowRectRelativeToSelf() + ToReferenceFrame();
}
nsDisplayItemGeometry* nsDisplayTableItem::AllocateGeometry(
nsDisplayListBuilder* aBuilder) {
return new nsDisplayTableItemGeometry(
this, aBuilder, mFrame->GetOffsetTo(mFrame->PresShell()->GetRootFrame()));
}
void nsDisplayTableItem::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
auto geometry = static_cast<const nsDisplayTableItemGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
}
nsDisplayTableBackgroundSet::nsDisplayTableBackgroundSet(
nsDisplayListBuilder* aBuilder, nsIFrame* aTable)
: mBuilder(aBuilder),

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

@ -47,12 +47,6 @@ class nsDisplayTableItem : public nsPaintedDisplayItem {
// cells extending outside them.
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) const override;
virtual nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override;
virtual void ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
};
class nsDisplayTableBackgroundSet {

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

@ -504,10 +504,8 @@ void nsDisplayXULImage::Paint(nsDisplayListBuilder* aBuilder,
if (aBuilder->UseHighQualityScaling())
flags |= imgIContainer::FLAG_HIGH_QUALITY_SCALING;
ImgDrawResult result = static_cast<nsImageBoxFrame*>(mFrame)->PaintImage(
Unused << static_cast<nsImageBoxFrame*>(mFrame)->PaintImage(
*aCtx, GetPaintRect(aBuilder, aCtx), ToReferenceFrame(), flags);
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
bool nsDisplayXULImage::CreateWebRenderCommands(
@ -540,32 +538,9 @@ bool nsDisplayXULImage::CreateWebRenderCommands(
return false;
}
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
return true;
}
nsDisplayItemGeometry* nsDisplayXULImage::AllocateGeometry(
nsDisplayListBuilder* aBuilder) {
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void nsDisplayXULImage::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const {
auto boxFrame = static_cast<nsImageBoxFrame*>(mFrame);
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() && boxFrame->mImageRequest &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsPaintedDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry,
aInvalidRegion);
}
bool nsImageBoxFrame::CanOptimizeToImageLayer() {
bool hasSubRect = !mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0);
if (hasSubRect) {

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

@ -168,11 +168,6 @@ class nsDisplayXULImage final : public nsPaintedDisplayItem {
*aSnap = true;
return nsRect(ToReferenceFrame(), Frame()->GetSize());
}
virtual nsDisplayItemGeometry* AllocateGeometry(
nsDisplayListBuilder* aBuilder) override;
virtual void ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const override;
// Doesn't handle HitTest because nsLeafBoxFrame already creates an
// event receiver for us
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;

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

@ -2511,9 +2511,7 @@ class nsDisplayTreeBody final : public nsPaintedDisplayItem {
nsRegion* aInvalidRegion) const override {
auto geometry = static_cast<const nsDisplayTreeBodyGeometry*>(aGeometry);
if ((aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) ||
IsWindowActive() != geometry->mWindowIsActive) {
if (IsWindowActive() != geometry->mWindowIsActive) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
@ -2525,10 +2523,8 @@ class nsDisplayTreeBody final : public nsPaintedDisplayItem {
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override {
MOZ_ASSERT(aBuilder);
ImgDrawResult result = static_cast<nsTreeBodyFrame*>(mFrame)->PaintTreeBody(
Unused << static_cast<nsTreeBodyFrame*>(mFrame)->PaintTreeBody(
*aCtx, GetPaintRect(aBuilder, aCtx), ToReferenceFrame(), aBuilder);
nsDisplayTreeBodyGeometry::UpdateDrawResult(this, result);
}
NS_DISPLAY_DECL_NAME("XULTreeBody", TYPE_XUL_TREE_BODY)