Bug 1621835. Make imgINotificationObserver::Notify a void method, since no one examines its return value anyway. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D66513

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2020-03-12 01:46:16 +00:00
Родитель cb551719ad
Коммит e5766424b8
22 изменённых файлов: 161 добавлений и 213 удалений

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

@ -142,9 +142,8 @@ nsImageLoadingContent::~nsImageLoadingContent() {
/*
* imgINotificationObserver impl
*/
NS_IMETHODIMP
nsImageLoadingContent::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void nsImageLoadingContent::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
MOZ_ASSERT(aRequest, "no request?");
MOZ_ASSERT(aRequest == mCurrentRequest || aRequest == mPendingRequest,
"Forgot to cancel a previous request?");
@ -155,7 +154,7 @@ nsImageLoadingContent::Notify(imgIRequest* aRequest, int32_t aType,
if (aType == imgINotificationObserver::UNLOCKED_DRAW) {
OnUnlockedDraw();
return NS_OK;
return;
}
{
@ -225,12 +224,10 @@ nsImageLoadingContent::Notify(imgIRequest* aRequest, int32_t aType,
UpdateImageState(true);
}
return NS_OK;
}
nsresult nsImageLoadingContent::OnLoadComplete(imgIRequest* aRequest,
nsresult aStatus) {
void nsImageLoadingContent::OnLoadComplete(imgIRequest* aRequest,
nsresult aStatus) {
uint32_t oldStatus;
aRequest->GetImageStatus(&oldStatus);
@ -242,8 +239,9 @@ nsresult nsImageLoadingContent::OnLoadComplete(imgIRequest* aRequest,
// to punt when the given request doesn't appear to have terminated in
// an expected state.
if (!(oldStatus &
(imgIRequest::STATUS_ERROR | imgIRequest::STATUS_LOAD_COMPLETE)))
return NS_OK;
(imgIRequest::STATUS_ERROR | imgIRequest::STATUS_LOAD_COMPLETE))) {
return;
}
// Our state may change. Watch it.
AutoStateChanger changer(this, true);
@ -273,8 +271,6 @@ nsresult nsImageLoadingContent::OnLoadComplete(imgIRequest* aRequest,
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
SVGObserverUtils::InvalidateDirectRenderingObservers(thisNode->AsElement());
MaybeResolveDecodePromises();
return NS_OK;
}
static bool ImageIsAnimated(imgIRequest* aRequest) {
@ -327,14 +323,12 @@ void nsImageLoadingContent::OnUnlockedDraw() {
presShell->EnsureFrameInApproximatelyVisibleList(frame);
}
nsresult nsImageLoadingContent::OnImageIsAnimated(imgIRequest* aRequest) {
void nsImageLoadingContent::OnImageIsAnimated(imgIRequest* aRequest) {
bool* requestFlag = GetRegisteredFlagForRequest(aRequest);
if (requestFlag) {
nsLayoutUtils::RegisterImageRequest(GetFramePresContext(), aRequest,
requestFlag);
}
return NS_OK;
}
/*

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

@ -219,9 +219,9 @@ class nsImageLoadingContent : public nsIImageLoadingContent {
void BindToTree(mozilla::dom::BindContext&, nsINode& aParent);
void UnbindFromTree(bool aNullParent);
nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
void OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
void OnUnlockedDraw();
nsresult OnImageIsAnimated(imgIRequest* aRequest);
void OnImageIsAnimated(imgIRequest* aRequest);
// The nsContentPolicyType we would use for this ImageLoadType
static nsContentPolicyType PolicyTypeForLoad(ImageLoadType aImageLoadType);

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

@ -475,9 +475,8 @@ void ImageDocument::NotifyPossibleTitleChange(bool aBoundTitleElement) {
Document::NotifyPossibleTitleChange(aBoundTitleElement);
}
NS_IMETHODIMP
ImageDocument::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void ImageDocument::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
@ -500,8 +499,6 @@ ImageDocument::Notify(imgIRequest* aRequest, int32_t aType,
reqStatus & imgIRequest::STATUS_ERROR ? NS_ERROR_FAILURE : NS_OK;
return OnLoadComplete(aRequest, status);
}
return NS_OK;
}
void ImageDocument::OnHasTransparency() {
@ -539,8 +536,8 @@ void ImageDocument::SetModeClass(eModeClasses mode) {
rv.SuppressException();
}
nsresult ImageDocument::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
void ImageDocument::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
int32_t oldWidth = mImageWidth;
int32_t oldHeight = mImageHeight;
@ -553,7 +550,7 @@ nsresult ImageDocument::OnSizeAvailable(imgIRequest* aRequest,
// doesn't change our size. (We may not even support changing size in
// multipart images in the future.)
if (oldWidth == mImageWidth && oldHeight == mImageHeight) {
return NS_OK;
return;
}
nsCOMPtr<nsIRunnable> runnable =
@ -561,12 +558,9 @@ nsresult ImageDocument::OnSizeAvailable(imgIRequest* aRequest,
&ImageDocument::DefaultCheckOverflowing);
nsContentUtils::AddScriptRunner(runnable);
UpdateTitleAndCharset();
return NS_OK;
}
nsresult ImageDocument::OnLoadComplete(imgIRequest* aRequest,
nsresult aStatus) {
void ImageDocument::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus) {
UpdateTitleAndCharset();
// mImageContent can be null if the document is already destroyed
@ -580,8 +574,6 @@ nsresult ImageDocument::OnLoadComplete(imgIRequest* aRequest,
mImageContent->SetAttr(kNameSpaceID_None, nsGkAtoms::alt, errorMsg, false);
}
return NS_OK;
}
NS_IMETHODIMP

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

@ -104,8 +104,8 @@ class ImageDocument final : public MediaDocument,
};
void SetModeClass(eModeClasses mode);
nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
void OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
void OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
void OnHasTransparency();
nsCOMPtr<Element> mImageContent;

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

@ -319,10 +319,9 @@ SVGFEImageElement::FrameCreated(nsIFrame* aFrame) {
//----------------------------------------------------------------------
// imgINotificationObserver methods
NS_IMETHODIMP
SVGFEImageElement::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
nsresult rv = nsImageLoadingContent::Notify(aRequest, aType, aData);
void SVGFEImageElement::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
nsImageLoadingContent::Notify(aRequest, aType, aData);
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
// Request a decode
@ -341,8 +340,6 @@ SVGFEImageElement::Notify(imgIRequest* aRequest, int32_t aType,
static_cast<SVGFilterElement*>(GetParent()));
}
}
return rv;
}
} // namespace dom

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

@ -69,8 +69,8 @@ class SVGFEImageElement final : public SVGFEImageElementBase,
virtual void UnbindFromTree(bool aNullParent) override;
virtual EventStates IntrinsicState() const override;
NS_IMETHOD Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) override;
void Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) override;
// Override for nsIImageLoadingContent.
NS_IMETHOD_(void) FrameCreated(nsIFrame* aFrame) override;

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

@ -26,9 +26,8 @@ ScriptedNotificationObserver::ScriptedNotificationObserver(
imgIScriptedNotificationObserver* aInner)
: mInner(aInner) {}
NS_IMETHODIMP
ScriptedNotificationObserver::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* /*aUnused*/) {
void ScriptedNotificationObserver::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* /*aUnused*/) {
// For now, we block (other) scripts from running to preserve the historical
// behavior from when ScriptedNotificationObserver::Notify was called as part
// of the observers list in nsImageLoadingContent::Notify. Now each
@ -37,30 +36,37 @@ ScriptedNotificationObserver::Notify(imgIRequest* aRequest, int32_t aType,
nsAutoScriptBlocker scriptBlocker;
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
return mInner->SizeAvailable(aRequest);
mInner->SizeAvailable(aRequest);
return;
}
if (aType == imgINotificationObserver::FRAME_UPDATE) {
return mInner->FrameUpdate(aRequest);
mInner->FrameUpdate(aRequest);
return;
}
if (aType == imgINotificationObserver::FRAME_COMPLETE) {
return mInner->FrameComplete(aRequest);
mInner->FrameComplete(aRequest);
return;
}
if (aType == imgINotificationObserver::DECODE_COMPLETE) {
return mInner->DecodeComplete(aRequest);
mInner->DecodeComplete(aRequest);
return;
}
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
return mInner->LoadComplete(aRequest);
mInner->LoadComplete(aRequest);
return;
}
if (aType == imgINotificationObserver::DISCARD) {
return mInner->Discard(aRequest);
mInner->Discard(aRequest);
return;
}
if (aType == imgINotificationObserver::IS_ANIMATED) {
return mInner->IsAnimated(aRequest);
mInner->IsAnimated(aRequest);
return;
}
if (aType == imgINotificationObserver::HAS_TRANSPARENCY) {
return mInner->HasTransparency(aRequest);
mInner->HasTransparency(aRequest);
return;
}
return NS_OK;
}
} // namespace image

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

@ -53,6 +53,7 @@ interface imgINotificationObserver : nsISupports
// The image is transparent.
const long HAS_TRANSPARENCY = 9;
[noscript] void notify(in imgIRequest aProxy, in long aType,
[const] in nsIntRect aRect);
[noscript, notxpcom, nostdcall]
void notify(in imgIRequest aProxy, in long aType,
[const] in nsIntRect aRect);
};

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

@ -1041,9 +1041,8 @@ void nsBulletFrame::AddInlinePrefISize(gfxContext* aRenderingContext,
}
}
NS_IMETHODIMP
nsBulletFrame::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void nsBulletFrame::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
@ -1097,8 +1096,6 @@ nsBulletFrame::Notify(imgIRequest* aRequest, int32_t aType,
}
}
}
return NS_OK;
}
Document* nsBulletFrame::GetOurCurrentDoc() const {
@ -1106,15 +1103,15 @@ Document* nsBulletFrame::GetOurCurrentDoc() const {
return parentContent ? parentContent->GetComposedDoc() : nullptr;
}
nsresult nsBulletFrame::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
if (!aImage) return NS_ERROR_INVALID_ARG;
if (!aRequest) return NS_ERROR_INVALID_ARG;
void nsBulletFrame::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
if (!aImage) return;
if (!aRequest) return;
uint32_t status;
aRequest->GetImageStatus(&status);
if (status & imgIRequest::STATUS_ERROR) {
return NS_OK;
return;
}
nscoord w, h;
@ -1145,8 +1142,6 @@ nsresult nsBulletFrame::OnSizeAvailable(imgIRequest* aRequest,
// corresponding call to Decrement for this. This Increment will be
// 'cleaned up' by the Request when it is destroyed, but only then.
aRequest->IncrementAnimationConsumers();
return NS_OK;
}
void nsBulletFrame::GetLoadGroup(nsPresContext* aPresContext,
@ -1326,11 +1321,10 @@ nsBulletListener::nsBulletListener() : mFrame(nullptr) {}
nsBulletListener::~nsBulletListener() {}
NS_IMETHODIMP
nsBulletListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void nsBulletListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (!mFrame) {
return NS_ERROR_FAILURE;
return;
}
return mFrame->Notify(aRequest, aType, aData);
}

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

@ -57,8 +57,7 @@ class nsBulletFrame final : public nsFrame {
virtual ~nsBulletFrame();
NS_IMETHOD Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData);
void Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData);
// nsIFrame
virtual void DestroyFrom(nsIFrame* aDestructRoot,
@ -129,7 +128,7 @@ class nsBulletFrame final : public nsFrame {
already_AddRefed<imgIContainer> GetImage() const;
protected:
nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
void OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
void AppendSpacingToPadding(nsFontMetrics* aFontMetrics,
mozilla::LogicalMargin* aPadding);

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

@ -673,8 +673,8 @@ bool nsImageFrame::ShouldCreateImageFrameFor(const Element& aElement,
return false;
}
nsresult nsImageFrame::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aRect) {
void nsImageFrame::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aRect) {
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
@ -702,14 +702,12 @@ nsresult nsImageFrame::Notify(imgIRequest* aRequest, int32_t aType,
imgStatus & imgIRequest::STATUS_ERROR ? NS_ERROR_FAILURE : NS_OK;
return OnLoadComplete(aRequest, status);
}
return NS_OK;
}
nsresult nsImageFrame::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
void nsImageFrame::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
if (!aImage) {
return NS_ERROR_INVALID_ARG;
return;
}
/* Get requested animation policy from the pres context:
@ -721,11 +719,10 @@ nsresult nsImageFrame::OnSizeAvailable(imgIRequest* aRequest,
if (IsPendingLoad(aRequest)) {
// We don't care
return NS_OK;
return;
}
UpdateImage(aRequest, aImage);
return NS_OK;
}
void nsImageFrame::UpdateImage(imgIRequest* aRequest, imgIContainer* aImage) {
@ -769,22 +766,24 @@ void nsImageFrame::UpdateImage(imgIRequest* aRequest, imgIContainer* aImage) {
}
}
nsresult nsImageFrame::OnFrameUpdate(imgIRequest* aRequest,
const nsIntRect* aRect) {
NS_ENSURE_ARG_POINTER(aRect);
void nsImageFrame::OnFrameUpdate(imgIRequest* aRequest,
const nsIntRect* aRect) {
if (NS_WARN_IF(!aRect)) {
return;
}
if (!GotInitialReflow()) {
// Don't bother to do anything; we have a reflow coming up!
return NS_OK;
return;
}
if (mFirstFrameComplete && !StyleVisibility()->IsVisible()) {
return NS_OK;
return;
}
if (IsPendingLoad(aRequest)) {
// We don't care
return NS_OK;
return;
}
nsIntRect layerInvalidRect =
@ -793,12 +792,11 @@ nsresult nsImageFrame::OnFrameUpdate(imgIRequest* aRequest,
if (layerInvalidRect.IsEqualInterior(GetMaxSizedIntRect())) {
// Invalidate our entire area.
InvalidateSelf(nullptr, nullptr);
return NS_OK;
return;
}
nsRect frameInvalidRect = SourceRectToDest(layerInvalidRect);
InvalidateSelf(&layerInvalidRect, &frameInvalidRect);
return NS_OK;
}
void nsImageFrame::InvalidateSelf(const nsIntRect* aLayerInvalidRect,
@ -820,9 +818,8 @@ void nsImageFrame::InvalidateSelf(const nsIntRect* aLayerInvalidRect,
}
}
nsresult nsImageFrame::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus) {
void nsImageFrame::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus) {
NotifyNewCurrentRequest(aRequest, aStatus);
return NS_OK;
}
void nsImageFrame::ResponsiveContentDensityChanged() {
@ -2609,21 +2606,20 @@ nsresult nsImageFrame::StopAnimation() {
return NS_OK;
}
NS_IMETHODIMP
nsImageFrame::IconLoad::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void nsImageFrame::IconLoad::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
MOZ_ASSERT(aRequest);
if (aType != imgINotificationObserver::LOAD_COMPLETE &&
aType != imgINotificationObserver::FRAME_UPDATE) {
return NS_OK;
return;
}
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
if (!image) {
return NS_ERROR_FAILURE;
return;
}
// Retrieve the image's intrinsic size.
@ -2644,8 +2640,6 @@ nsImageFrame::IconLoad::Notify(imgIRequest* aRequest, int32_t aType,
frame = iter.GetNext();
frame->InvalidateFrame();
}
return NS_OK;
}
NS_IMPL_ISUPPORTS(nsImageListener, imgINotificationObserver)
@ -2654,10 +2648,11 @@ nsImageListener::nsImageListener(nsImageFrame* aFrame) : mFrame(aFrame) {}
nsImageListener::~nsImageListener() = default;
NS_IMETHODIMP
nsImageListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (!mFrame) return NS_ERROR_FAILURE;
void nsImageListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (!mFrame) {
return;
}
return mFrame->Notify(aRequest, aType, aData);
}

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

@ -137,7 +137,7 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
nsresult StopAnimation();
already_AddRefed<imgIRequest> GetCurrentRequest() const;
nsresult Notify(imgIRequest*, int32_t aType, const nsIntRect* aData);
void Notify(imgIRequest*, int32_t aType, const nsIntRect* aData);
/**
* Function to test whether given an element and its style, that element
@ -267,9 +267,9 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
friend class nsImageLoadingContent;
friend class mozilla::PresShell;
nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
nsresult OnFrameUpdate(imgIRequest* aRequest, const nsIntRect* aRect);
nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
void OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
void OnFrameUpdate(imgIRequest* aRequest, const nsIntRect* aRect);
void OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
/**
* Notification that aRequest will now be the current request.

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

@ -630,13 +630,12 @@ void ImageLoader::RequestReflowOnFrame(FrameWithFlags* aFwf,
parent->PresShell()->PostReflowCallback(unblocker);
}
NS_IMETHODIMP
GlobalImageObserver::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void GlobalImageObserver::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
auto entry = sImages->Lookup(aRequest);
MOZ_DIAGNOSTIC_ASSERT(entry);
if (MOZ_UNLIKELY(!entry)) {
return NS_OK;
return;
}
auto& loaders = entry.Data()->mImageLoaders;
@ -647,11 +646,10 @@ GlobalImageObserver::Notify(imgIRequest* aRequest, int32_t aType,
for (auto& loader : loadersToNotify) {
loader->Notify(aRequest, aType, aData);
}
return NS_OK;
}
nsresult ImageLoader::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void ImageLoader::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
#ifdef MOZ_GECKO_PROFILER
nsCString uriString;
if (profiler_is_active()) {
@ -695,22 +693,20 @@ nsresult ImageLoader::Notify(imgIRequest* aRequest, int32_t aType,
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
return OnLoadComplete(aRequest);
}
return NS_OK;
}
nsresult ImageLoader::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
void ImageLoader::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
nsPresContext* presContext = GetPresContext();
if (!presContext) {
return NS_OK;
return;
}
aImage->SetAnimationMode(presContext->ImageAnimationMode());
FrameSet* frameSet = mRequestToFrameMap.Get(aRequest);
if (!frameSet) {
return NS_OK;
return;
}
for (const FrameWithFlags& fwf : *frameSet) {
@ -718,18 +714,16 @@ nsresult ImageLoader::OnSizeAvailable(imgIRequest* aRequest,
fwf.mFrame->SchedulePaint();
}
}
return NS_OK;
}
nsresult ImageLoader::OnImageIsAnimated(imgIRequest* aRequest) {
void ImageLoader::OnImageIsAnimated(imgIRequest* aRequest) {
if (!mDocument) {
return NS_OK;
return;
}
FrameSet* frameSet = mRequestToFrameMap.Get(aRequest);
if (!frameSet) {
return NS_OK;
return;
}
// Register with the refresh driver now that we are aware that
@ -738,18 +732,16 @@ nsresult ImageLoader::OnImageIsAnimated(imgIRequest* aRequest) {
if (presContext) {
nsLayoutUtils::RegisterImageRequest(presContext, aRequest, nullptr);
}
return NS_OK;
}
nsresult ImageLoader::OnFrameComplete(imgIRequest* aRequest) {
void ImageLoader::OnFrameComplete(imgIRequest* aRequest) {
if (!mDocument) {
return NS_OK;
return;
}
FrameSet* frameSet = mRequestToFrameMap.Get(aRequest);
if (!frameSet) {
return NS_OK;
return;
}
// We may need reflow (for example if the image is from shape-outside).
@ -759,33 +751,29 @@ nsresult ImageLoader::OnFrameComplete(imgIRequest* aRequest) {
// we're now able to paint an image that we couldn't paint before (and hence
// that we don't have retained data for).
RequestPaintIfNeeded(frameSet, aRequest, /* aForcePaint = */ true);
return NS_OK;
}
nsresult ImageLoader::OnFrameUpdate(imgIRequest* aRequest) {
void ImageLoader::OnFrameUpdate(imgIRequest* aRequest) {
if (!mDocument) {
return NS_OK;
return;
}
FrameSet* frameSet = mRequestToFrameMap.Get(aRequest);
if (!frameSet) {
return NS_OK;
return;
}
RequestPaintIfNeeded(frameSet, aRequest, /* aForcePaint = */ false);
return NS_OK;
}
nsresult ImageLoader::OnLoadComplete(imgIRequest* aRequest) {
void ImageLoader::OnLoadComplete(imgIRequest* aRequest) {
if (!mDocument) {
return NS_OK;
return;
}
FrameSet* frameSet = mRequestToFrameMap.Get(aRequest);
if (!frameSet) {
return NS_OK;
return;
}
// Check if aRequest has an error state. If it does, we need to unblock
@ -803,8 +791,6 @@ nsresult ImageLoader::OnLoadComplete(imgIRequest* aRequest) {
}
}
}
return NS_OK;
}
bool ImageLoader::ImageReflowCallback::ReflowFinished() {

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

@ -90,7 +90,7 @@ class ImageLoader final {
// This is called whenever an image we care about notifies the
// GlobalImageObserver.
nsresult Notify(imgIRequest*, int32_t aType, const nsIntRect* aData);
void Notify(imgIRequest*, int32_t aType, const nsIntRect* aData);
private:
// Called when we stop caring about a given request.
@ -155,11 +155,11 @@ class ImageLoader final {
void RequestReflowIfNeeded(FrameSet* aFrameSet, imgIRequest* aRequest);
void RequestReflowOnFrame(FrameWithFlags* aFwf, imgIRequest* aRequest);
nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
nsresult OnFrameComplete(imgIRequest* aRequest);
nsresult OnImageIsAnimated(imgIRequest* aRequest);
nsresult OnFrameUpdate(imgIRequest* aRequest);
nsresult OnLoadComplete(imgIRequest* aRequest);
void OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
void OnFrameComplete(imgIRequest* aRequest);
void OnImageIsAnimated(imgIRequest* aRequest);
void OnFrameUpdate(imgIRequest* aRequest);
void OnLoadComplete(imgIRequest* aRequest);
// Helpers for DropRequestsForFrame / DisassociateRequestFromFrame above.
void RemoveRequestToFrameMapping(imgIRequest* aRequest, nsIFrame* aFrame);

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

@ -547,11 +547,10 @@ NS_IMPL_ISUPPORTS(nsSVGImageListener, imgINotificationObserver)
nsSVGImageListener::nsSVGImageListener(nsSVGImageFrame* aFrame)
: mFrame(aFrame) {}
NS_IMETHODIMP
nsSVGImageListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void nsSVGImageListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (!mFrame) {
return NS_ERROR_FAILURE;
return;
}
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
@ -585,6 +584,4 @@ nsSVGImageListener::Notify(imgIRequest* aRequest, int32_t aType,
nsChangeHint_InvalidateRenderingObservers);
nsSVGUtils::ScheduleReflowSVG(mFrame);
}
return NS_OK;
}

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

@ -752,8 +752,8 @@ nsresult nsImageBoxFrame::GetFrameName(nsAString& aResult) const {
}
#endif
nsresult nsImageBoxFrame::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void nsImageBoxFrame::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
@ -779,13 +779,13 @@ nsresult nsImageBoxFrame::Notify(imgIRequest* aRequest, int32_t aType,
if (aType == imgINotificationObserver::FRAME_UPDATE) {
return OnFrameUpdate(aRequest);
}
return NS_OK;
}
nsresult nsImageBoxFrame::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
NS_ENSURE_ARG_POINTER(aImage);
void nsImageBoxFrame::OnSizeAvailable(imgIRequest* aRequest,
imgIContainer* aImage) {
if (NS_WARN_IF(!aImage)) {
return;
}
// Ensure the animation (if any) is started. Note: There is no
// corresponding call to Decrement for this. This Increment will be
@ -805,18 +805,14 @@ nsresult nsImageBoxFrame::OnSizeAvailable(imgIRequest* aRequest,
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::StyleChange,
NS_FRAME_IS_DIRTY);
}
return NS_OK;
}
nsresult nsImageBoxFrame::OnDecodeComplete(imgIRequest* aRequest) {
void nsImageBoxFrame::OnDecodeComplete(imgIRequest* aRequest) {
nsBoxLayoutState state(PresContext());
this->XULRedraw(state);
return NS_OK;
}
nsresult nsImageBoxFrame::OnLoadComplete(imgIRequest* aRequest,
nsresult aStatus) {
void nsImageBoxFrame::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus) {
if (NS_SUCCEEDED(aStatus)) {
// Fire an onload DOM event.
FireImageDOMEvent(mContent, eLoad);
@ -827,21 +823,17 @@ nsresult nsImageBoxFrame::OnLoadComplete(imgIRequest* aRequest,
NS_FRAME_IS_DIRTY);
FireImageDOMEvent(mContent, eLoadError);
}
return NS_OK;
}
nsresult nsImageBoxFrame::OnImageIsAnimated(imgIRequest* aRequest) {
void nsImageBoxFrame::OnImageIsAnimated(imgIRequest* aRequest) {
// Register with our refresh driver, if we're animated.
nsLayoutUtils::RegisterImageRequest(PresContext(), aRequest,
&mRequestRegistered);
return NS_OK;
}
nsresult nsImageBoxFrame::OnFrameUpdate(imgIRequest* aRequest) {
void nsImageBoxFrame::OnFrameUpdate(imgIRequest* aRequest) {
if ((0 == mRect.width) || (0 == mRect.height)) {
return NS_OK;
return;
}
// Check if WebRender has interacted with this frame. If it has
@ -849,12 +841,10 @@ nsresult nsImageBoxFrame::OnFrameUpdate(imgIRequest* aRequest) {
const auto type = DisplayItemType::TYPE_XUL_IMAGE;
const auto producerId = aRequest->GetProducerId();
if (WebRenderUserData::ProcessInvalidateForImage(this, type, producerId)) {
return NS_OK;
return;
}
InvalidateLayer(type);
return NS_OK;
}
NS_IMPL_ISUPPORTS(nsImageBoxListener, imgINotificationObserver)
@ -864,10 +854,11 @@ nsImageBoxListener::nsImageBoxListener(nsImageBoxFrame* frame)
nsImageBoxListener::~nsImageBoxListener() {}
NS_IMETHODIMP
nsImageBoxListener::Notify(imgIRequest* request, int32_t aType,
const nsIntRect* aData) {
if (!mFrame) return NS_OK;
void nsImageBoxListener::Notify(imgIRequest* request, int32_t aType,
const nsIntRect* aData) {
if (!mFrame) {
return;
}
return mFrame->Notify(request, aType, aData);
}

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

@ -52,7 +52,7 @@ class nsImageBoxFrame final : public nsLeafBoxFrame {
virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
virtual void MarkIntrinsicISizesDirty() override;
nsresult Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData);
void Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData);
friend nsIFrame* NS_NewImageBoxFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle);
@ -125,11 +125,11 @@ class nsImageBoxFrame final : public nsLeafBoxFrame {
virtual void GetImageSize();
private:
nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
nsresult OnDecodeComplete(imgIRequest* aRequest);
nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
nsresult OnImageIsAnimated(imgIRequest* aRequest);
nsresult OnFrameUpdate(imgIRequest* aRequest);
void OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
void OnDecodeComplete(imgIRequest* aRequest);
void OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
void OnImageIsAnimated(imgIRequest* aRequest);
void OnFrameUpdate(imgIRequest* aRequest);
nsRect mSubRect; ///< If set, indicates that only the portion of the image
///< specified by the rect should be used.

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

@ -4340,8 +4340,6 @@ bool nsTreeBodyFrame::FullScrollbarsUpdate(bool aNeedsFullInvalidation) {
return weakFrame.IsAlive();
}
nsresult nsTreeBodyFrame::OnImageIsAnimated(imgIRequest* aRequest) {
void nsTreeBodyFrame::OnImageIsAnimated(imgIRequest* aRequest) {
nsLayoutUtils::RegisterImageRequest(PresContext(), aRequest, nullptr);
return NS_OK;
}

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

@ -64,7 +64,7 @@ class nsTreeBodyFrame final : public nsLeafBoxFrame,
// Callback handler methods for refresh driver based animations.
// Calls to these functions are forwarded from nsTreeImageListener. These
// mirror how nsImageFrame works.
nsresult OnImageIsAnimated(imgIRequest* aRequest);
void OnImageIsAnimated(imgIRequest* aRequest);
// non-virtual signatures like nsITreeBodyFrame
already_AddRefed<nsTreeColumns> Columns() const {

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

@ -20,11 +20,13 @@ nsTreeImageListener::nsTreeImageListener(nsTreeBodyFrame* aTreeFrame)
nsTreeImageListener::~nsTreeImageListener() { delete mInvalidationArea; }
NS_IMETHODIMP
nsTreeImageListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void nsTreeImageListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (aType == imgINotificationObserver::IS_ANIMATED) {
return mTreeFrame ? mTreeFrame->OnImageIsAnimated(aRequest) : NS_OK;
if (mTreeFrame) {
mTreeFrame->OnImageIsAnimated(aRequest);
}
return;
}
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
@ -46,8 +48,6 @@ nsTreeImageListener::Notify(imgIRequest* aRequest, int32_t aType,
if (aType == imgINotificationObserver::FRAME_UPDATE) {
Invalidate();
}
return NS_OK;
}
void nsTreeImageListener::AddCell(int32_t aIndex, nsTreeColumn* aCol) {

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

@ -162,9 +162,9 @@ AlertNotification::LoadImage(uint32_t aTimeout,
RefPtr<AlertImageRequest> request = new AlertImageRequest(
imageURI, mPrincipal, mInPrivateBrowsing, aTimeout, aListener, aUserData);
nsresult rv = request->Start();
request->Start();
request.forget(aRequest);
return rv;
return NS_OK;
}
NS_IMPL_CYCLE_COLLECTION(AlertImageRequest, mURI, mPrincipal, mListener,
@ -198,15 +198,15 @@ AlertImageRequest::~AlertImageRequest() {
}
}
NS_IMETHODIMP
AlertImageRequest::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
void AlertImageRequest::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
MOZ_ASSERT(aRequest == mRequest);
uint32_t imgStatus = imgIRequest::STATUS_ERROR;
nsresult rv = aRequest->GetImageStatus(&imgStatus);
if (NS_WARN_IF(NS_FAILED(rv)) || (imgStatus & imgIRequest::STATUS_ERROR)) {
return NotifyMissing();
NotifyMissing();
return;
}
// If the image is already decoded, `FRAME_COMPLETE` will fire before
@ -219,7 +219,8 @@ AlertImageRequest::Notify(imgIRequest* aRequest, int32_t aType,
nsCOMPtr<imgIContainer> image;
rv = aRequest->GetImage(getter_AddRefs(image));
if (NS_WARN_IF(NS_FAILED(rv) || !image)) {
return NotifyMissing();
NotifyMissing();
return;
}
// Ask the image to decode at its intrinsic size.
@ -229,14 +230,12 @@ AlertImageRequest::Notify(imgIRequest* aRequest, int32_t aType,
image->RequestDecodeForSize(gfx::IntSize(width, height),
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
}
return NS_OK;
return;
}
if (aType == imgINotificationObserver::FRAME_COMPLETE) {
return NotifyComplete();
}
return NS_OK;
}
NS_IMETHODIMP
@ -314,21 +313,20 @@ nsresult AlertImageRequest::NotifyMissing() {
NS_RELEASE_THIS();
return rv;
}
return NS_OK;
}
nsresult AlertImageRequest::NotifyComplete() {
void AlertImageRequest::NotifyComplete() {
if (mTimer) {
mTimer->Cancel();
mTimer = nullptr;
}
if (nsCOMPtr<nsIAlertNotificationImageListener> listener =
std::move(mListener)) {
nsresult rv = listener->OnImageReady(mUserData, mRequest);
listener->OnImageReady(mUserData, mRequest);
NS_RELEASE_THIS();
return rv;
}
return NS_OK;
}
} // namespace mozilla

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

@ -41,7 +41,7 @@ class AlertImageRequest final : public imgINotificationObserver,
virtual ~AlertImageRequest();
nsresult NotifyMissing();
nsresult NotifyComplete();
void NotifyComplete();
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIPrincipal> mPrincipal;