Bug 1685078 - Remove some useless includes from ImageLoader.h. r=TYLin

Differential Revision: https://phabricator.services.mozilla.com/D101069
This commit is contained in:
Emilio Cobos Álvarez
2021-01-08 09:44:40 +00:00
parent 9c3fcd5d73
commit 016cc7d132
2 changed files with 53 additions and 48 deletions

View File

@@ -14,6 +14,7 @@
#include "mozilla/dom/DocumentInlines.h"
#include "mozilla/dom/ImageTracker.h"
#include "nsContentUtils.h"
#include "nsIReflowCallback.h"
#include "nsLayoutUtils.h"
#include "nsError.h"
#include "nsCanvasFrame.h"
@@ -21,6 +22,7 @@
#include "nsIFrameInlines.h"
#include "FrameLayerBuilder.h"
#include "imgIContainer.h"
#include "imgINotificationObserver.h"
#include "Image.h"
#include "GeckoProfiler.h"
#include "mozilla/PresShell.h"
@@ -590,6 +592,48 @@ void ImageLoader::RequestReflowIfNeeded(FrameSet* aFrameSet,
}
}
// This callback is used to unblock document onload after a reflow
// triggered from an image load.
struct ImageLoader::ImageReflowCallback final : public nsIReflowCallback {
RefPtr<ImageLoader> mLoader;
WeakFrame mFrame;
nsCOMPtr<imgIRequest> const mRequest;
ImageReflowCallback(ImageLoader* aLoader, nsIFrame* aFrame,
imgIRequest* aRequest)
: mLoader(aLoader), mFrame(aFrame), mRequest(aRequest) {}
bool ReflowFinished() override;
void ReflowCallbackCanceled() override;
};
bool ImageLoader::ImageReflowCallback::ReflowFinished() {
// Check that the frame is still valid. If it isn't, then onload was
// unblocked when the frame was removed from the FrameSet in
// RemoveRequestToFrameMapping.
if (mFrame.IsAlive()) {
mLoader->UnblockOnloadIfNeeded(mFrame, mRequest);
}
// Get rid of this callback object.
delete this;
// We don't need to trigger layout.
return false;
}
void ImageLoader::ImageReflowCallback::ReflowCallbackCanceled() {
// Check that the frame is still valid. If it isn't, then onload was
// unblocked when the frame was removed from the FrameSet in
// RemoveRequestToFrameMapping.
if (mFrame.IsAlive()) {
mLoader->UnblockOnloadIfNeeded(mFrame, mRequest);
}
// Get rid of this callback object.
delete this;
}
void ImageLoader::RequestReflowOnFrame(FrameWithFlags* aFwf,
imgIRequest* aRequest) {
nsIFrame* frame = aFwf->mFrame;
@@ -771,32 +815,5 @@ void ImageLoader::OnLoadComplete(imgIRequest* aRequest) {
}
}
bool ImageLoader::ImageReflowCallback::ReflowFinished() {
// Check that the frame is still valid. If it isn't, then onload was
// unblocked when the frame was removed from the FrameSet in
// RemoveRequestToFrameMapping.
if (mFrame.IsAlive()) {
mLoader->UnblockOnloadIfNeeded(mFrame, mRequest);
}
// Get rid of this callback object.
delete this;
// We don't need to trigger layout.
return false;
}
void ImageLoader::ImageReflowCallback::ReflowCallbackCanceled() {
// Check that the frame is still valid. If it isn't, then onload was
// unblocked when the frame was removed from the FrameSet in
// RemoveRequestToFrameMapping.
if (mFrame.IsAlive()) {
mLoader->UnblockOnloadIfNeeded(mFrame, mRequest);
}
// Get rid of this callback object.
delete this;
}
} // namespace css
} // namespace mozilla

View File

@@ -13,20 +13,22 @@
#include "mozilla/CORSMode.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsIFrame.h"
#include "nsIReflowCallback.h"
#include "nsRect.h"
#include "nsTArray.h"
#include "imgIRequest.h"
#include "imgINotificationObserver.h"
#include "mozilla/Attributes.h"
class nsIFrame;
class imgIContainer;
class imgIRequest;
class imgRequestProxy;
class nsPresContext;
class nsIURI;
class nsIPrincipal;
class nsIRequest;
namespace mozilla {
struct MediaFeatureChange;
struct StyleComputedUrl;
namespace dom {
class Document;
}
@@ -73,8 +75,8 @@ class ImageLoader final {
void ClearFrames(nsPresContext* aPresContext);
// Triggers an image load.
static already_AddRefed<imgRequestProxy> LoadImage(
const StyleComputedImageUrl&, dom::Document&);
static already_AddRefed<imgRequestProxy> LoadImage(const StyleComputedUrl&,
dom::Document&);
// Usually, only one style value owns a given proxy. However, we have a hack
// to share image proxies in chrome documents under some circumstances. We
@@ -94,21 +96,7 @@ class ImageLoader final {
private:
// Called when we stop caring about a given request.
void DeregisterImageRequest(imgIRequest*, nsPresContext*);
// This callback is used to unblock document onload after a reflow
// triggered from an image load.
struct ImageReflowCallback final : public nsIReflowCallback {
RefPtr<ImageLoader> mLoader;
WeakFrame mFrame;
nsCOMPtr<imgIRequest> const mRequest;
ImageReflowCallback(ImageLoader* aLoader, nsIFrame* aFrame,
imgIRequest* aRequest)
: mLoader(aLoader), mFrame(aFrame), mRequest(aRequest) {}
bool ReflowFinished() override;
void ReflowCallbackCanceled() override;
};
struct ImageReflowCallback;
~ImageLoader() = default;