Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef __NS_SVGMASKFRAME_H__ |
michael@0 | 7 | #define __NS_SVGMASKFRAME_H__ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "gfxPattern.h" |
michael@0 | 11 | #include "gfxMatrix.h" |
michael@0 | 12 | #include "nsSVGContainerFrame.h" |
michael@0 | 13 | #include "nsSVGUtils.h" |
michael@0 | 14 | |
michael@0 | 15 | class gfxContext; |
michael@0 | 16 | class nsRenderingContext; |
michael@0 | 17 | |
michael@0 | 18 | typedef nsSVGContainerFrame nsSVGMaskFrameBase; |
michael@0 | 19 | |
michael@0 | 20 | class nsSVGMaskFrame : public nsSVGMaskFrameBase |
michael@0 | 21 | { |
michael@0 | 22 | friend nsIFrame* |
michael@0 | 23 | NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 24 | protected: |
michael@0 | 25 | nsSVGMaskFrame(nsStyleContext* aContext) |
michael@0 | 26 | : nsSVGMaskFrameBase(aContext) |
michael@0 | 27 | , mInUse(false) |
michael@0 | 28 | { |
michael@0 | 29 | AddStateBits(NS_FRAME_IS_NONDISPLAY); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | public: |
michael@0 | 33 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 34 | |
michael@0 | 35 | // nsSVGMaskFrame method: |
michael@0 | 36 | already_AddRefed<gfxPattern> ComputeMaskAlpha(nsRenderingContext *aContext, |
michael@0 | 37 | nsIFrame* aParent, |
michael@0 | 38 | const gfxMatrix &aMatrix, |
michael@0 | 39 | float aOpacity = 1.0f); |
michael@0 | 40 | |
michael@0 | 41 | virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
michael@0 | 42 | nsIAtom* aAttribute, |
michael@0 | 43 | int32_t aModType) MOZ_OVERRIDE; |
michael@0 | 44 | |
michael@0 | 45 | #ifdef DEBUG |
michael@0 | 46 | virtual void Init(nsIContent* aContent, |
michael@0 | 47 | nsIFrame* aParent, |
michael@0 | 48 | nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
michael@0 | 49 | #endif |
michael@0 | 50 | |
michael@0 | 51 | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 52 | const nsRect& aDirtyRect, |
michael@0 | 53 | const nsDisplayListSet& aLists) MOZ_OVERRIDE {} |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * Get the "type" of the frame |
michael@0 | 57 | * |
michael@0 | 58 | * @see nsGkAtoms::svgMaskFrame |
michael@0 | 59 | */ |
michael@0 | 60 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 61 | |
michael@0 | 62 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 63 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE |
michael@0 | 64 | { |
michael@0 | 65 | return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult); |
michael@0 | 66 | } |
michael@0 | 67 | #endif |
michael@0 | 68 | |
michael@0 | 69 | private: |
michael@0 | 70 | // A helper class to allow us to paint masks safely. The helper |
michael@0 | 71 | // automatically sets and clears the mInUse flag on the mask frame |
michael@0 | 72 | // (to prevent nasty reference loops). It's easy to mess this up |
michael@0 | 73 | // and break things, so this helper makes the code far more robust. |
michael@0 | 74 | class MOZ_STACK_CLASS AutoMaskReferencer |
michael@0 | 75 | { |
michael@0 | 76 | public: |
michael@0 | 77 | AutoMaskReferencer(nsSVGMaskFrame *aFrame |
michael@0 | 78 | MOZ_GUARD_OBJECT_NOTIFIER_PARAM) |
michael@0 | 79 | : mFrame(aFrame) { |
michael@0 | 80 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
michael@0 | 81 | NS_ASSERTION(!mFrame->mInUse, "reference loop!"); |
michael@0 | 82 | mFrame->mInUse = true; |
michael@0 | 83 | } |
michael@0 | 84 | ~AutoMaskReferencer() { |
michael@0 | 85 | mFrame->mInUse = false; |
michael@0 | 86 | } |
michael@0 | 87 | private: |
michael@0 | 88 | nsSVGMaskFrame *mFrame; |
michael@0 | 89 | MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | nsIFrame *mMaskParent; |
michael@0 | 93 | nsAutoPtr<gfxMatrix> mMaskParentMatrix; |
michael@0 | 94 | // recursion prevention flag |
michael@0 | 95 | bool mInUse; |
michael@0 | 96 | |
michael@0 | 97 | // nsSVGContainerFrame methods: |
michael@0 | 98 | virtual gfxMatrix GetCanvasTM(uint32_t aFor, |
michael@0 | 99 | nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE; |
michael@0 | 100 | }; |
michael@0 | 101 | |
michael@0 | 102 | #endif |