image/src/ImageWrapper.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/image/src/ImageWrapper.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef MOZILLA_IMAGELIB_IMAGEWRAPPER_H_
    1.10 +#define MOZILLA_IMAGELIB_IMAGEWRAPPER_H_
    1.11 +
    1.12 +#include "mozilla/MemoryReporting.h"
    1.13 +#include "Image.h"
    1.14 +
    1.15 +namespace mozilla {
    1.16 +namespace image {
    1.17 +
    1.18 +/**
    1.19 + * Abstract superclass for Images that wrap other Images.
    1.20 + */
    1.21 +class ImageWrapper : public Image
    1.22 +{
    1.23 +public:
    1.24 +  NS_DECL_ISUPPORTS
    1.25 +  NS_DECL_IMGICONTAINER
    1.26 +
    1.27 +  virtual ~ImageWrapper() { }
    1.28 +
    1.29 +  // Inherited methods from Image.
    1.30 +  virtual nsresult Init(const char* aMimeType, uint32_t aFlags) MOZ_OVERRIDE;
    1.31 +
    1.32 +  virtual already_AddRefed<imgStatusTracker> GetStatusTracker() MOZ_OVERRIDE;
    1.33 +  virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
    1.34 +
    1.35 +  virtual uint32_t SizeOfData() MOZ_OVERRIDE;
    1.36 +  virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
    1.37 +  virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
    1.38 +  virtual size_t NonHeapSizeOfDecoded() const MOZ_OVERRIDE;
    1.39 +  virtual size_t OutOfProcessSizeOfDecoded() const MOZ_OVERRIDE;
    1.40 +
    1.41 +  virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
    1.42 +  virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
    1.43 +#ifdef DEBUG
    1.44 +  virtual uint32_t GetAnimationConsumers() MOZ_OVERRIDE;
    1.45 +#endif
    1.46 +
    1.47 +  virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
    1.48 +                                        nsISupports* aContext,
    1.49 +                                        nsIInputStream* aInStr,
    1.50 +                                        uint64_t aSourceOffset,
    1.51 +                                        uint32_t aCount) MOZ_OVERRIDE;
    1.52 +  virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
    1.53 +                                       nsISupports* aContext,
    1.54 +                                       nsresult aStatus,
    1.55 +                                       bool aLastPart) MOZ_OVERRIDE;
    1.56 +  virtual nsresult OnNewSourceData() MOZ_OVERRIDE;
    1.57 +
    1.58 +  virtual void SetInnerWindowID(uint64_t aInnerWindowId) MOZ_OVERRIDE;
    1.59 +  virtual uint64_t InnerWindowID() const MOZ_OVERRIDE;
    1.60 +
    1.61 +  virtual bool HasError() MOZ_OVERRIDE;
    1.62 +  virtual void SetHasError() MOZ_OVERRIDE;
    1.63 +
    1.64 +  virtual ImageURL* GetURI() MOZ_OVERRIDE;
    1.65 +
    1.66 +protected:
    1.67 +  ImageWrapper(Image* aInnerImage)
    1.68 +    : mInnerImage(aInnerImage)
    1.69 +  {
    1.70 +    NS_ABORT_IF_FALSE(aInnerImage, "Cannot wrap a null image");
    1.71 +  }
    1.72 +
    1.73 +  /**
    1.74 +   * Returns a weak reference to the inner image wrapped by this ImageWrapper.
    1.75 +   */
    1.76 +  Image* InnerImage() { return mInnerImage.get(); }
    1.77 +
    1.78 +private:
    1.79 +  nsRefPtr<Image> mInnerImage;
    1.80 +};
    1.81 +
    1.82 +} // namespace image
    1.83 +} // namespace mozilla
    1.84 +
    1.85 +#endif // MOZILLA_IMAGELIB_IMAGEWRAPPER_H_

mercurial