1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef __NS_SVGMASKFRAME_H__
7 #define __NS_SVGMASKFRAME_H__
9 #include "mozilla/Attributes.h"
10 #include "gfxPattern.h"
11 #include "gfxMatrix.h"
12 #include "nsSVGContainerFrame.h"
13 #include "nsSVGUtils.h"
16 class nsRenderingContext
;
18 typedef nsSVGContainerFrame nsSVGMaskFrameBase
;
20 class nsSVGMaskFrame MOZ_FINAL
: public nsSVGMaskFrameBase
23 NS_NewSVGMaskFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
25 explicit nsSVGMaskFrame(nsStyleContext
* aContext
)
26 : nsSVGMaskFrameBase(aContext
)
29 AddStateBits(NS_FRAME_IS_NONDISPLAY
);
33 NS_DECL_FRAMEARENA_HELPERS
35 // nsSVGMaskFrame method:
36 already_AddRefed
<gfxPattern
> GetMaskForMaskedFrame(gfxContext
* aContext
,
37 nsIFrame
* aMaskedFrame
,
38 const gfxMatrix
&aMatrix
,
41 virtual nsresult
AttributeChanged(int32_t aNameSpaceID
,
43 int32_t aModType
) MOZ_OVERRIDE
;
46 virtual void Init(nsIContent
* aContent
,
47 nsContainerFrame
* aParent
,
48 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
51 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
52 const nsRect
& aDirtyRect
,
53 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
{}
56 * Get the "type" of the frame
58 * @see nsGkAtoms::svgMaskFrame
60 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
62 #ifdef DEBUG_FRAME_DUMP
63 virtual nsresult
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
65 return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult
);
70 // A helper class to allow us to paint masks safely. The helper
71 // automatically sets and clears the mInUse flag on the mask frame
72 // (to prevent nasty reference loops). It's easy to mess this up
73 // and break things, so this helper makes the code far more robust.
74 class MOZ_STACK_CLASS AutoMaskReferencer
77 explicit AutoMaskReferencer(nsSVGMaskFrame
*aFrame
78 MOZ_GUARD_OBJECT_NOTIFIER_PARAM
)
80 MOZ_GUARD_OBJECT_NOTIFIER_INIT
;
81 NS_ASSERTION(!mFrame
->mInUse
, "reference loop!");
82 mFrame
->mInUse
= true;
84 ~AutoMaskReferencer() {
85 mFrame
->mInUse
= false;
88 nsSVGMaskFrame
*mFrame
;
89 MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
92 nsIFrame
*mMaskParent
;
93 nsAutoPtr
<gfxMatrix
> mMaskParentMatrix
;
94 // recursion prevention flag
97 // nsSVGContainerFrame methods:
98 virtual gfxMatrix
GetCanvasTM(uint32_t aFor
,
99 nsIFrame
* aTransformRoot
= nullptr) MOZ_OVERRIDE
;