mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1349477, part 4 - Use AutoReferenceChainGuard in nsSVGMaskFrame. r=longsonr
MozReview-Commit-ID: 5tVLBcTOLQZ
This commit is contained in:
parent
1fdd3184b8
commit
2773e5508d
@ -7,6 +7,7 @@
|
||||
#include "nsSVGMaskFrame.h"
|
||||
|
||||
// Keep others in (case-insensitive) order:
|
||||
#include "AutoReferenceChainGuard.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxContext.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
@ -204,14 +205,14 @@ NS_IMPL_FRAMEARENA_HELPERS(nsSVGMaskFrame)
|
||||
mozilla::Pair<DrawResult, RefPtr<SourceSurface>>
|
||||
nsSVGMaskFrame::GetMaskForMaskedFrame(MaskParams& aParams)
|
||||
{
|
||||
// If the flag is set when we get here, it means this mask frame
|
||||
// has already been used painting the current mask, and the document
|
||||
// has a mask reference loop.
|
||||
if (mInUse) {
|
||||
NS_WARNING("Mask loop detected!");
|
||||
// Make sure we break reference loops and over long reference chains:
|
||||
static int16_t sRefChainLengthCounter = AutoReferenceChainGuard::noChain;
|
||||
AutoReferenceChainGuard refChainGuard(this, &mInUse,
|
||||
&sRefChainLengthCounter);
|
||||
if (MOZ_UNLIKELY(!refChainGuard.Reference())) {
|
||||
// Break reference chain
|
||||
return MakePair(DrawResult::SUCCESS, RefPtr<SourceSurface>());
|
||||
}
|
||||
AutoMaskReferencer maskRef(this);
|
||||
|
||||
gfxRect maskArea = GetMaskArea(aParams.maskedFrame);
|
||||
gfxContext* context = aParams.ctx;
|
||||
|
@ -111,28 +111,6 @@ private:
|
||||
*/
|
||||
gfxMatrix GetMaskTransform(nsIFrame* aMaskedFrame);
|
||||
|
||||
// A helper class to allow us to paint masks safely. The helper
|
||||
// automatically sets and clears the mInUse flag on the mask frame
|
||||
// (to prevent nasty reference loops). It's easy to mess this up
|
||||
// and break things, so this helper makes the code far more robust.
|
||||
class MOZ_RAII AutoMaskReferencer
|
||||
{
|
||||
public:
|
||||
explicit AutoMaskReferencer(nsSVGMaskFrame *aFrame
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mFrame(aFrame) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
NS_ASSERTION(!mFrame->mInUse, "reference loop!");
|
||||
mFrame->mInUse = true;
|
||||
}
|
||||
~AutoMaskReferencer() {
|
||||
mFrame->mInUse = false;
|
||||
}
|
||||
private:
|
||||
nsSVGMaskFrame *mFrame;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
gfxMatrix mMatrixForChildren;
|
||||
// recursion prevention flag
|
||||
bool mInUse;
|
||||
|
Loading…
Reference in New Issue
Block a user