mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 1349388, part 3 - Provide AutoReferenceLimiter with a default maximum reference chain length. r=longsonr
This commit is contained in:
parent
6f850d0f40
commit
618c7360e8
@ -63,11 +63,13 @@ namespace mozilla {
|
||||
*/
|
||||
class MOZ_RAII AutoReferenceLimiter
|
||||
{
|
||||
static const int16_t sDefaultMaxChainLength = 10; // arbitrary number
|
||||
|
||||
public:
|
||||
static const int16_t notReferencing = -2;
|
||||
|
||||
AutoReferenceLimiter(nsIFrame* aFrame, int16_t* aRefCounter,
|
||||
int16_t aMaxReferenceCount
|
||||
int16_t aMaxReferenceCount = sDefaultMaxChainLength
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
|
@ -21,9 +21,6 @@ using namespace mozilla::dom;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::image;
|
||||
|
||||
// Arbitrary number
|
||||
#define MAX_SVG_CLIP_PATH_REFERENCE_CHAIN_LENGTH int16_t(512)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
||||
@ -129,12 +126,13 @@ nsSVGClipPathFrame::PaintClipMask(gfxContext& aMaskContext,
|
||||
SourceSurface* aExtraMask,
|
||||
const Matrix& aExtraMasksTransform)
|
||||
{
|
||||
// A clipPath can reference another clipPath. We re-enter this method for
|
||||
// each clipPath in a reference chain, so here we limit chain length:
|
||||
static int16_t sRefChainLengthCounter = AutoReferenceLimiter::notReferencing;
|
||||
AutoReferenceLimiter
|
||||
refChainLengthLimiter(this, &sRefChainLengthCounter,
|
||||
MAX_SVG_CLIP_PATH_REFERENCE_CHAIN_LENGTH);
|
||||
|
||||
// A clipPath can reference another clipPath, creating a chain of clipPaths
|
||||
// that must all be applied. We re-enter this method for each clipPath in a
|
||||
// chain, so here we limit the chain length by limiting the number of
|
||||
// re-entries:
|
||||
AutoReferenceLimiter refChainLengthLimiter(this, &sRefChainLengthCounter);
|
||||
if (!refChainLengthLimiter.Reference()) {
|
||||
return DrawResult::SUCCESS; // Reference chain is too long!
|
||||
}
|
||||
@ -298,12 +296,14 @@ bool
|
||||
nsSVGClipPathFrame::PointIsInsideClipPath(nsIFrame* aClippedFrame,
|
||||
const gfxPoint &aPoint)
|
||||
{
|
||||
// A clipPath can reference another clipPath. We re-enter this method for
|
||||
// each clipPath in a reference chain, so here we limit chain length:
|
||||
static int16_t sRefChainLengthCounter = AutoReferenceLimiter::notReferencing;
|
||||
|
||||
// A clipPath can reference another clipPath, creating a chain of clipPaths
|
||||
// that must all be applied. We re-enter this method for each clipPath in a
|
||||
// chain, so here we limit the chain length by limiting the number of
|
||||
// re-entries:
|
||||
AutoReferenceLimiter
|
||||
refChainLengthLimiter(this, &sRefChainLengthCounter,
|
||||
MAX_SVG_CLIP_PATH_REFERENCE_CHAIN_LENGTH);
|
||||
refChainLengthLimiter(this, &sRefChainLengthCounter);
|
||||
if (!refChainLengthLimiter.Reference()) {
|
||||
return false; // Reference chain is too long!
|
||||
}
|
||||
@ -393,12 +393,14 @@ nsSVGClipPathFrame::IsTrivial(nsSVGDisplayableFrame **aSingleChild)
|
||||
bool
|
||||
nsSVGClipPathFrame::IsValid()
|
||||
{
|
||||
// A clipPath can reference another clipPath. We re-enter this method for
|
||||
// each clipPath in a reference chain, so here we limit chain length:
|
||||
static int16_t sRefChainLengthCounter = AutoReferenceLimiter::notReferencing;
|
||||
|
||||
// A clipPath can reference another clipPath, creating a chain of clipPaths
|
||||
// that must all be applied. We re-enter this method for each clipPath in a
|
||||
// chain, so here we limit the chain length by limiting the number of
|
||||
// re-entries:
|
||||
AutoReferenceLimiter
|
||||
refChainLengthLimiter(this, &sRefChainLengthCounter,
|
||||
MAX_SVG_CLIP_PATH_REFERENCE_CHAIN_LENGTH);
|
||||
refChainLengthLimiter(this, &sRefChainLengthCounter);
|
||||
if (!refChainLengthLimiter.Reference()) {
|
||||
return false; // Reference chain is too long!
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user