зеркало из https://github.com/mozilla/gecko-dev.git
Bug 920630 - Part 3. Change Image/ImageResource and derived classes to use nsIURI directly instead of ImageURL. r=tnikkel
This commit is contained in:
Родитель
218069997c
Коммит
ce228623ab
|
@ -104,8 +104,8 @@ void
|
|||
DynamicImage::SetHasError()
|
||||
{ }
|
||||
|
||||
ImageURL*
|
||||
DynamicImage::GetURI()
|
||||
nsIURI*
|
||||
DynamicImage::GetURI() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
virtual bool HasError() override;
|
||||
virtual void SetHasError() override;
|
||||
|
||||
virtual ImageURL* GetURI() override;
|
||||
nsIURI* GetURI() const override;
|
||||
|
||||
private:
|
||||
virtual ~DynamicImage() { }
|
||||
|
|
|
@ -26,7 +26,7 @@ ImageMemoryCounter::ImageMemoryCounter(Image* aImage,
|
|||
MOZ_ASSERT(aImage);
|
||||
|
||||
// Extract metadata about the image.
|
||||
RefPtr<ImageURL> imageURL(aImage->GetURI());
|
||||
nsCOMPtr<nsIURI> imageURL(aImage->GetURI());
|
||||
if (imageURL) {
|
||||
imageURL->GetSpec(mURI);
|
||||
}
|
||||
|
@ -54,6 +54,20 @@ ImageMemoryCounter::ImageMemoryCounter(Image* aImage,
|
|||
// Image Base Types
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool
|
||||
ImageResource::GetSpecTruncatedTo1k(nsCString& aSpec) const
|
||||
{
|
||||
static const size_t sMaxTruncatedLength = 1024;
|
||||
|
||||
mURI->GetSpec(aSpec);
|
||||
if (sMaxTruncatedLength >= aSpec.Length()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
aSpec.Truncate(sMaxTruncatedLength);
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
ImageResource::SetCurrentImage(ImageContainer* aContainer,
|
||||
SourceSurface* aSurface,
|
||||
|
@ -269,7 +283,7 @@ ImageResource::ReleaseImageContainer()
|
|||
}
|
||||
|
||||
// Constructor
|
||||
ImageResource::ImageResource(ImageURL* aURI) :
|
||||
ImageResource::ImageResource(nsIURI* aURI) :
|
||||
mURI(aURI),
|
||||
mInnerWindowId(0),
|
||||
mAnimationConsumers(0),
|
||||
|
@ -404,7 +418,7 @@ ImageResource::NotifyDrawingObservers()
|
|||
}
|
||||
|
||||
// Record the image drawing for startup performance testing.
|
||||
nsCOMPtr<nsIURI> uri = mURI->ToIURI();
|
||||
nsCOMPtr<nsIURI> uri = mURI;
|
||||
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
|
||||
"image::ImageResource::NotifyDrawingObservers", [uri]() {
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "mozilla/TimeStamp.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "ImageURL.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "LookupResult.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
@ -233,7 +232,7 @@ public:
|
|||
virtual bool HasError() = 0;
|
||||
virtual void SetHasError() = 0;
|
||||
|
||||
virtual ImageURL* GetURI() = 0;
|
||||
virtual nsIURI* GetURI() const = 0;
|
||||
|
||||
virtual void ReportUseCounters() { }
|
||||
};
|
||||
|
@ -279,12 +278,14 @@ public:
|
|||
* Returns a non-AddRefed pointer to the URI associated with this image.
|
||||
* Illegal to use off-main-thread.
|
||||
*/
|
||||
virtual ImageURL* GetURI() override { return mURI.get(); }
|
||||
nsIURI* GetURI() const override { return mURI; }
|
||||
|
||||
protected:
|
||||
explicit ImageResource(ImageURL* aURI);
|
||||
explicit ImageResource(nsIURI* aURI);
|
||||
~ImageResource();
|
||||
|
||||
bool GetSpecTruncatedTo1k(nsCString& aSpec) const;
|
||||
|
||||
// Shared functionality for implementors of imgIContainer. Every
|
||||
// implementation of attribute animationMode should forward here.
|
||||
nsresult GetAnimationModeInternal(uint16_t* aAnimationMode);
|
||||
|
@ -326,8 +327,8 @@ protected:
|
|||
#endif
|
||||
|
||||
// Member data shared by all implementations of this abstract class
|
||||
RefPtr<ProgressTracker> mProgressTracker;
|
||||
RefPtr<ImageURL> mURI;
|
||||
RefPtr<ProgressTracker> mProgressTracker;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
TimeStamp mLastRefreshTime;
|
||||
uint64_t mInnerWindowId;
|
||||
uint32_t mAnimationConsumers;
|
||||
|
|
|
@ -34,7 +34,7 @@ ImageFactory::Initialize()
|
|||
{ }
|
||||
|
||||
static uint32_t
|
||||
ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
|
||||
ComputeImageFlags(nsIURI* uri, const nsCString& aMimeType, bool isMultiPart)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -88,10 +88,10 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
|
|||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
NotifyImageLoading(ImageURL* aURI)
|
||||
NotifyImageLoading(nsIURI* aURI)
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
RefPtr<ImageURL> uri(aURI);
|
||||
nsCOMPtr<nsIURI> uri(aURI);
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
NS_NewRunnableFunction("NotifyImageLoading", [uri] () -> void {
|
||||
NotifyImageLoading(uri);
|
||||
|
@ -114,7 +114,7 @@ NotifyImageLoading(ImageURL* aURI)
|
|||
ImageFactory::CreateImage(nsIRequest* aRequest,
|
||||
ProgressTracker* aProgressTracker,
|
||||
const nsCString& aMimeType,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
bool aIsMultiPart,
|
||||
uint32_t aInnerWindowId)
|
||||
{
|
||||
|
@ -240,7 +240,7 @@ GetContentSize(nsIRequest* aRequest)
|
|||
ImageFactory::CreateRasterImage(nsIRequest* aRequest,
|
||||
ProgressTracker* aProgressTracker,
|
||||
const nsCString& aMimeType,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
uint32_t aImageFlags,
|
||||
uint32_t aInnerWindowId)
|
||||
{
|
||||
|
@ -271,7 +271,7 @@ ImageFactory::CreateRasterImage(nsIRequest* aRequest,
|
|||
ImageFactory::CreateVectorImage(nsIRequest* aRequest,
|
||||
ProgressTracker* aProgressTracker,
|
||||
const nsCString& aMimeType,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
uint32_t aImageFlags,
|
||||
uint32_t aInnerWindowId)
|
||||
{
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
#include "nsStringFwd.h"
|
||||
|
||||
class nsIRequest;
|
||||
class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
|
||||
class Image;
|
||||
class ImageURL;
|
||||
class MultipartImage;
|
||||
class ProgressTracker;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
static already_AddRefed<Image> CreateImage(nsIRequest* aRequest,
|
||||
ProgressTracker* aProgressTracker,
|
||||
const nsCString& aMimeType,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
bool aIsMultiPart,
|
||||
uint32_t aInnerWindowId);
|
||||
/**
|
||||
|
@ -74,7 +74,7 @@ private:
|
|||
CreateRasterImage(nsIRequest* aRequest,
|
||||
ProgressTracker* aProgressTracker,
|
||||
const nsCString& aMimeType,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
uint32_t aImageFlags,
|
||||
uint32_t aInnerWindowId);
|
||||
|
||||
|
@ -82,7 +82,7 @@ private:
|
|||
CreateVectorImage(nsIRequest* aRequest,
|
||||
ProgressTracker* aProgressTracker,
|
||||
const nsCString& aMimeType,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
uint32_t aImageFlags,
|
||||
uint32_t aInnerWindowId);
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ ImageWrapper::SetHasError()
|
|||
mInnerImage->SetHasError();
|
||||
}
|
||||
|
||||
ImageURL*
|
||||
ImageWrapper::GetURI()
|
||||
nsIURI*
|
||||
ImageWrapper::GetURI() const
|
||||
{
|
||||
return mInnerImage->GetURI();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
virtual bool HasError() override;
|
||||
virtual void SetHasError() override;
|
||||
|
||||
virtual ImageURL* GetURI() override;
|
||||
nsIURI* GetURI() const override;
|
||||
|
||||
protected:
|
||||
explicit ImageWrapper(Image* aInnerImage)
|
||||
|
|
|
@ -70,7 +70,7 @@ NS_IMPL_ISUPPORTS(RasterImage, imgIContainer, nsIProperties,
|
|||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
RasterImage::RasterImage(ImageURL* aURI /* = nullptr */) :
|
||||
RasterImage::RasterImage(nsIURI* aURI /* = nullptr */) :
|
||||
ImageResource(aURI), // invoke superclass's constructor
|
||||
mSize(0,0),
|
||||
mLockCount(0),
|
||||
|
@ -1817,8 +1817,8 @@ RasterImage::ReportDecoderError()
|
|||
nsAutoString msg(NS_LITERAL_STRING("Image corrupt or truncated."));
|
||||
nsAutoString src;
|
||||
if (GetURI()) {
|
||||
nsCString uri;
|
||||
if (GetURI()->GetSpecTruncatedTo1k(uri) == ImageURL::TruncatedTo1k) {
|
||||
nsAutoCString uri;
|
||||
if (!GetSpecTruncatedTo1k(uri)) {
|
||||
msg += NS_LITERAL_STRING(" URI in this note truncated due to length.");
|
||||
}
|
||||
src = NS_ConvertUTF8toUTF16(uri);
|
||||
|
|
|
@ -469,7 +469,7 @@ private: // data
|
|||
DrawableSurface RequestDecodeForSizeInternal(const gfx::IntSize& aSize, uint32_t aFlags);
|
||||
|
||||
protected:
|
||||
explicit RasterImage(ImageURL* aURI = nullptr);
|
||||
explicit RasterImage(nsIURI* aURI = nullptr);
|
||||
|
||||
bool ShouldAnimate() override;
|
||||
|
||||
|
|
|
@ -371,7 +371,7 @@ NS_IMPL_ISUPPORTS(VectorImage,
|
|||
//------------------------------------------------------------------------------
|
||||
// Constructor / Destructor
|
||||
|
||||
VectorImage::VectorImage(ImageURL* aURI /* = nullptr */) :
|
||||
VectorImage::VectorImage(nsIURI* aURI /* = nullptr */) :
|
||||
ImageResource(aURI), // invoke superclass's constructor
|
||||
mLockCount(0),
|
||||
mIsInitialized(false),
|
||||
|
@ -922,8 +922,7 @@ VectorImage::MaybeRestrictSVGContext(Maybe<SVGImageContext>& aNewSVGContext,
|
|||
bool haveContextPaint = aSVGContext && aSVGContext->GetContextPaint();
|
||||
bool blockContextPaint = false;
|
||||
if (haveContextPaint) {
|
||||
nsCOMPtr<nsIURI> imageURI = mURI->ToIURI();
|
||||
blockContextPaint = !SVGContextPaint::IsAllowedForImageFromURI(imageURI);
|
||||
blockContextPaint = !SVGContextPaint::IsAllowedForImageFromURI(mURI);
|
||||
}
|
||||
|
||||
if (overridePAR || blockContextPaint) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
virtual void ReportUseCounters() override;
|
||||
|
||||
protected:
|
||||
explicit VectorImage(ImageURL* aURI = nullptr);
|
||||
explicit VectorImage(nsIURI* aURI = nullptr);
|
||||
virtual ~VectorImage();
|
||||
|
||||
virtual nsresult StartAnimation() override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче