зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1708443 - Part 3. Move VectorImage::mIsDrawing to SVGDocumentWrapper. r=tnikkel
Moving mIsDrawing to SVGDocumentWrapper allows us to avoid depending on VectorImage in a future patch, and instead only keep a reference to SVGDocumentWrapper. This helps avoid a circular dependency. Differential Revision: https://phabricator.services.mozilla.com/D111903
This commit is contained in:
Родитель
44db24fc2d
Коммит
0154638e9d
|
@ -19,9 +19,9 @@ namespace image {
|
|||
class MOZ_STACK_CLASS AutoRestoreSVGState final {
|
||||
public:
|
||||
AutoRestoreSVGState(const SVGDrawingParameters& aParams,
|
||||
SVGDocumentWrapper* aSVGDocumentWrapper, bool& aIsDrawing,
|
||||
SVGDocumentWrapper* aSVGDocumentWrapper,
|
||||
bool aContextPaint)
|
||||
: mIsDrawing(aIsDrawing)
|
||||
: mIsDrawing(aSVGDocumentWrapper->mIsDrawing)
|
||||
// Apply any 'preserveAspectRatio' override (if specified) to the root
|
||||
// element:
|
||||
,
|
||||
|
@ -29,10 +29,10 @@ class MOZ_STACK_CLASS AutoRestoreSVGState final {
|
|||
// Set the animation time:
|
||||
,
|
||||
mTime(aSVGDocumentWrapper->GetRootSVGElem(), aParams.animationTime) {
|
||||
MOZ_ASSERT(!aIsDrawing);
|
||||
MOZ_ASSERT(!mIsDrawing.SavedValue());
|
||||
MOZ_ASSERT(aSVGDocumentWrapper->GetDocument());
|
||||
|
||||
aIsDrawing = true;
|
||||
aSVGDocumentWrapper->mIsDrawing = true;
|
||||
|
||||
// Set context paint (if specified) on the document:
|
||||
if (aContextPaint) {
|
||||
|
|
|
@ -42,7 +42,9 @@ NS_IMPL_ISUPPORTS(SVGDocumentWrapper, nsIStreamListener, nsIRequestObserver,
|
|||
nsIObserver, nsISupportsWeakReference)
|
||||
|
||||
SVGDocumentWrapper::SVGDocumentWrapper()
|
||||
: mIgnoreInvalidation(false), mRegisteredForXPCOMShutdown(false) {}
|
||||
: mIgnoreInvalidation(false),
|
||||
mRegisteredForXPCOMShutdown(false),
|
||||
mIsDrawing(false) {}
|
||||
|
||||
SVGDocumentWrapper::~SVGDocumentWrapper() {
|
||||
DestroyViewer();
|
||||
|
|
|
@ -31,10 +31,11 @@ class SVGDocument;
|
|||
} // namespace dom
|
||||
|
||||
namespace image {
|
||||
class AutoRestoreSVGState;
|
||||
|
||||
class SVGDocumentWrapper final : public nsIStreamListener,
|
||||
public nsIObserver,
|
||||
nsSupportsWeakReference {
|
||||
public nsSupportsWeakReference {
|
||||
public:
|
||||
SVGDocumentWrapper();
|
||||
|
||||
|
@ -101,6 +102,13 @@ class SVGDocumentWrapper final : public nsIStreamListener,
|
|||
*/
|
||||
bool ShouldIgnoreInvalidation() { return mIgnoreInvalidation; }
|
||||
|
||||
/**
|
||||
* Returns a bool indicating whether the document is currently drawing.
|
||||
*
|
||||
* @return true if the document is drawing. Else, false.
|
||||
*/
|
||||
bool IsDrawing() const { return mIsDrawing; }
|
||||
|
||||
/**
|
||||
* Methods to control animation.
|
||||
*/
|
||||
|
@ -117,6 +125,8 @@ class SVGDocumentWrapper final : public nsIStreamListener,
|
|||
void FlushLayout();
|
||||
|
||||
private:
|
||||
friend class AutoRestoreSVGState;
|
||||
|
||||
~SVGDocumentWrapper();
|
||||
|
||||
nsresult SetupViewer(nsIRequest* aRequest, nsIContentViewer** aViewer,
|
||||
|
@ -130,9 +140,18 @@ class SVGDocumentWrapper final : public nsIStreamListener,
|
|||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
bool mIgnoreInvalidation;
|
||||
bool mRegisteredForXPCOMShutdown;
|
||||
bool mIsDrawing;
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
* Casting SVGDocumentWrapper to nsISupports is ambiguous. This method handles
|
||||
* that.
|
||||
*/
|
||||
inline nsISupports* ToSupports(mozilla::image::SVGDocumentWrapper* p) {
|
||||
return NS_ISUPPORTS_CAST(nsSupportsWeakReference*, p);
|
||||
}
|
||||
|
||||
#endif // mozilla_image_SVGDocumentWrapper_h
|
||||
|
|
|
@ -309,7 +309,6 @@ VectorImage::VectorImage(nsIURI* aURI /* = nullptr */)
|
|||
mIsInitialized(false),
|
||||
mDiscardable(false),
|
||||
mIsFullyLoaded(false),
|
||||
mIsDrawing(false),
|
||||
mHaveAnimations(false),
|
||||
mHasPendingInvalidation(false) {}
|
||||
|
||||
|
@ -717,7 +716,7 @@ VectorImage::GetFrameInternal(const IntSize& aSize,
|
|||
std::move(sourceSurface));
|
||||
}
|
||||
|
||||
if (mIsDrawing) {
|
||||
if (mSVGDocumentWrapper->IsDrawing()) {
|
||||
NS_WARNING("Refusing to make re-entrant call to VectorImage::Draw");
|
||||
return MakeTuple(ImgDrawResult::TEMPORARY_ERROR, decodeSize,
|
||||
RefPtr<SourceSurface>());
|
||||
|
@ -736,8 +735,7 @@ VectorImage::GetFrameInternal(const IntSize& aSize,
|
|||
bool didCache; // Was the surface put into the cache?
|
||||
bool contextPaint = aSVGContext && aSVGContext->GetContextPaint();
|
||||
|
||||
AutoRestoreSVGState autoRestore(params, mSVGDocumentWrapper, mIsDrawing,
|
||||
contextPaint);
|
||||
AutoRestoreSVGState autoRestore(params, mSVGDocumentWrapper, contextPaint);
|
||||
|
||||
RefPtr<gfxDrawable> svgDrawable = CreateSVGDrawable(params);
|
||||
RefPtr<SourceSurface> surface = CreateSurface(params, svgDrawable, didCache);
|
||||
|
@ -935,13 +933,12 @@ VectorImage::Draw(gfxContext* aContext, const nsIntSize& aSize,
|
|||
|
||||
// else, we need to paint the image:
|
||||
|
||||
if (mIsDrawing) {
|
||||
if (mSVGDocumentWrapper->IsDrawing()) {
|
||||
NS_WARNING("Refusing to make re-entrant call to VectorImage::Draw");
|
||||
return ImgDrawResult::TEMPORARY_ERROR;
|
||||
}
|
||||
|
||||
AutoRestoreSVGState autoRestore(params, mSVGDocumentWrapper, mIsDrawing,
|
||||
contextPaint);
|
||||
AutoRestoreSVGState autoRestore(params, mSVGDocumentWrapper, contextPaint);
|
||||
|
||||
bool didCache; // Was the surface put into the cache?
|
||||
RefPtr<gfxDrawable> svgDrawable = CreateSVGDrawable(params);
|
||||
|
@ -1014,7 +1011,7 @@ Tuple<RefPtr<SourceSurface>, IntSize> VectorImage::LookupCachedSurface(
|
|||
already_AddRefed<SourceSurface> VectorImage::CreateSurface(
|
||||
const SVGDrawingParameters& aParams, gfxDrawable* aSVGDrawable,
|
||||
bool& aWillCache) {
|
||||
MOZ_ASSERT(mIsDrawing);
|
||||
MOZ_ASSERT(mSVGDocumentWrapper->IsDrawing());
|
||||
|
||||
mSVGDocumentWrapper->UpdateViewportBounds(aParams.viewportSize);
|
||||
mSVGDocumentWrapper->FlushImageTransformInvalidation();
|
||||
|
|
|
@ -150,7 +150,6 @@ class VectorImage final : public ImageResource, public nsIStreamListener {
|
|||
bool mDiscardable; // Are we discardable?
|
||||
bool mIsFullyLoaded; // Has the SVG document finished
|
||||
// loading?
|
||||
bool mIsDrawing; // Are we currently drawing?
|
||||
bool mHaveAnimations; // Is our SVG content SMIL-animated?
|
||||
// (Only set after mIsFullyLoaded.)
|
||||
bool mHasPendingInvalidation; // Invalidate observers next refresh
|
||||
|
|
Загрузка…
Ссылка в новой задаче