Bumping manifests a=b2g-bump
[gecko.git] / layout / svg / nsSVGMaskFrame.h
blobfc5d60c70ac5bcb86ffb3c6f949e83e6180d66a1
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"
15 class gfxContext;
16 class nsRenderingContext;
18 typedef nsSVGContainerFrame nsSVGMaskFrameBase;
20 class nsSVGMaskFrame MOZ_FINAL : public nsSVGMaskFrameBase
22 friend nsIFrame*
23 NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
24 protected:
25 explicit nsSVGMaskFrame(nsStyleContext* aContext)
26 : nsSVGMaskFrameBase(aContext)
27 , mInUse(false)
29 AddStateBits(NS_FRAME_IS_NONDISPLAY);
32 public:
33 NS_DECL_FRAMEARENA_HELPERS
35 // nsSVGMaskFrame method:
36 already_AddRefed<gfxPattern> GetMaskForMaskedFrame(gfxContext* aContext,
37 nsIFrame* aMaskedFrame,
38 const gfxMatrix &aMatrix,
39 float aOpacity);
41 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
42 nsIAtom* aAttribute,
43 int32_t aModType) MOZ_OVERRIDE;
45 #ifdef DEBUG
46 virtual void Init(nsIContent* aContent,
47 nsContainerFrame* aParent,
48 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
49 #endif
51 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
52 const nsRect& aDirtyRect,
53 const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
55 /**
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);
67 #endif
69 private:
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
76 public:
77 explicit AutoMaskReferencer(nsSVGMaskFrame *aFrame
78 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
79 : mFrame(aFrame) {
80 MOZ_GUARD_OBJECT_NOTIFIER_INIT;
81 NS_ASSERTION(!mFrame->mInUse, "reference loop!");
82 mFrame->mInUse = true;
84 ~AutoMaskReferencer() {
85 mFrame->mInUse = false;
87 private:
88 nsSVGMaskFrame *mFrame;
89 MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
92 nsIFrame *mMaskParent;
93 nsAutoPtr<gfxMatrix> mMaskParentMatrix;
94 // recursion prevention flag
95 bool mInUse;
97 // nsSVGContainerFrame methods:
98 virtual gfxMatrix GetCanvasTM(uint32_t aFor,
99 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
102 #endif