2010-09-08 20:40:39 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-09-08 20:40:39 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_imagelib_VectorImage_h_
|
|
|
|
#define mozilla_imagelib_VectorImage_h_
|
|
|
|
|
|
|
|
#include "Image.h"
|
|
|
|
#include "nsIStreamListener.h"
|
2012-12-17 22:05:18 +00:00
|
|
|
#include "nsIRequest.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2012-12-18 16:37:15 +00:00
|
|
|
#include "mozilla/WeakPtr.h"
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2012-12-18 16:37:15 +00:00
|
|
|
class imgDecoderObserver;
|
2010-09-08 20:40:39 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2011-11-09 03:14:41 +00:00
|
|
|
namespace layers {
|
|
|
|
class LayerManager;
|
|
|
|
class ImageContainer;
|
|
|
|
}
|
2012-01-06 16:02:27 +00:00
|
|
|
namespace image {
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
class SVGDocumentWrapper;
|
2010-09-08 20:40:40 +00:00
|
|
|
class SVGRootRenderingObserver;
|
2013-02-14 02:04:08 +00:00
|
|
|
class SVGLoadEventListener;
|
|
|
|
class SVGParseCompleteListener;
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2012-12-19 22:24:32 +00:00
|
|
|
class VectorImage : public ImageResource,
|
2010-09-08 20:40:39 +00:00
|
|
|
public nsIStreamListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
2012-10-19 20:27:11 +00:00
|
|
|
NS_DECL_IMGICONTAINER
|
2010-11-17 20:37:08 +00:00
|
|
|
|
2012-12-17 22:05:18 +00:00
|
|
|
// (no public constructor - use ImageFactory)
|
2010-09-08 20:40:39 +00:00
|
|
|
virtual ~VectorImage();
|
|
|
|
|
|
|
|
// Methods inherited from Image
|
2013-02-13 03:00:03 +00:00
|
|
|
nsresult Init(const char* aMimeType,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags);
|
2013-02-05 00:06:14 +00:00
|
|
|
virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
|
2011-07-18 13:20:27 +00:00
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
|
|
virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-02-20 03:51:48 +00:00
|
|
|
virtual size_t NonHeapSizeOfDecoded() const;
|
|
|
|
virtual size_t OutOfProcessSizeOfDecoded() const;
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2012-12-17 22:05:18 +00:00
|
|
|
virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsIInputStream* aInStr,
|
|
|
|
uint64_t aSourceOffset,
|
|
|
|
uint32_t aCount) MOZ_OVERRIDE;
|
|
|
|
virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
|
|
|
|
nsISupports* aContext,
|
2013-02-14 02:41:10 +00:00
|
|
|
nsresult aResult,
|
|
|
|
bool aLastPart) MOZ_OVERRIDE;
|
2012-12-17 22:05:18 +00:00
|
|
|
virtual nsresult OnNewSourceData() MOZ_OVERRIDE;
|
|
|
|
|
2013-02-14 02:04:08 +00:00
|
|
|
// Callback for SVGRootRenderingObserver.
|
2010-09-08 20:40:40 +00:00
|
|
|
void InvalidateObserver();
|
|
|
|
|
2013-02-14 02:04:08 +00:00
|
|
|
// Callback for SVGParseCompleteListener.
|
|
|
|
void OnSVGDocumentParsed();
|
|
|
|
|
|
|
|
// Callbacks for SVGLoadEventListener.
|
|
|
|
void OnSVGDocumentLoaded();
|
|
|
|
void OnSVGDocumentError();
|
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
protected:
|
2012-12-19 21:28:54 +00:00
|
|
|
VectorImage(imgStatusTracker* aStatusTracker = nullptr, nsIURI* aURI = nullptr);
|
2012-12-17 22:05:18 +00:00
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
virtual nsresult StartAnimation();
|
|
|
|
virtual nsresult StopAnimation();
|
2011-08-05 13:57:16 +00:00
|
|
|
virtual bool ShouldAnimate();
|
2010-09-08 20:40:39 +00:00
|
|
|
|
|
|
|
private:
|
2013-02-14 02:04:08 +00:00
|
|
|
void CancelAllListeners();
|
|
|
|
|
2010-09-08 20:40:39 +00:00
|
|
|
nsRefPtr<SVGDocumentWrapper> mSVGDocumentWrapper;
|
2010-09-08 20:40:40 +00:00
|
|
|
nsRefPtr<SVGRootRenderingObserver> mRenderingObserver;
|
2013-02-14 02:04:08 +00:00
|
|
|
nsRefPtr<SVGLoadEventListener> mLoadEventListener;
|
|
|
|
nsRefPtr<SVGParseCompleteListener> mParseCompleteListener;
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2013-03-01 06:44:57 +00:00
|
|
|
bool mIsInitialized; // Have we been initalized?
|
|
|
|
bool mIsFullyLoaded; // Has the SVG document finished loading?
|
|
|
|
bool mIsDrawing; // Are we currently drawing?
|
|
|
|
bool mHaveAnimations; // Is our SVG content SMIL-animated?
|
2010-09-08 20:40:39 +00:00
|
|
|
// (Only set after mIsFullyLoaded.)
|
2012-12-17 22:05:18 +00:00
|
|
|
|
|
|
|
friend class ImageFactory;
|
2010-09-08 20:40:39 +00:00
|
|
|
};
|
|
|
|
|
2012-10-19 20:27:11 +00:00
|
|
|
inline NS_IMETHODIMP VectorImage::GetAnimationMode(uint16_t *aAnimationMode) {
|
|
|
|
return GetAnimationModeInternal(aAnimationMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline NS_IMETHODIMP VectorImage::SetAnimationMode(uint16_t aAnimationMode) {
|
|
|
|
return SetAnimationModeInternal(aAnimationMode);
|
|
|
|
}
|
|
|
|
|
2012-01-06 16:02:27 +00:00
|
|
|
} // namespace image
|
2010-09-08 20:40:39 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_imagelib_VectorImage_h_
|