1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/svg/nsSVGMaskFrame.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef __NS_SVGMASKFRAME_H__ 1.10 +#define __NS_SVGMASKFRAME_H__ 1.11 + 1.12 +#include "mozilla/Attributes.h" 1.13 +#include "gfxPattern.h" 1.14 +#include "gfxMatrix.h" 1.15 +#include "nsSVGContainerFrame.h" 1.16 +#include "nsSVGUtils.h" 1.17 + 1.18 +class gfxContext; 1.19 +class nsRenderingContext; 1.20 + 1.21 +typedef nsSVGContainerFrame nsSVGMaskFrameBase; 1.22 + 1.23 +class nsSVGMaskFrame : public nsSVGMaskFrameBase 1.24 +{ 1.25 + friend nsIFrame* 1.26 + NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); 1.27 +protected: 1.28 + nsSVGMaskFrame(nsStyleContext* aContext) 1.29 + : nsSVGMaskFrameBase(aContext) 1.30 + , mInUse(false) 1.31 + { 1.32 + AddStateBits(NS_FRAME_IS_NONDISPLAY); 1.33 + } 1.34 + 1.35 +public: 1.36 + NS_DECL_FRAMEARENA_HELPERS 1.37 + 1.38 + // nsSVGMaskFrame method: 1.39 + already_AddRefed<gfxPattern> ComputeMaskAlpha(nsRenderingContext *aContext, 1.40 + nsIFrame* aParent, 1.41 + const gfxMatrix &aMatrix, 1.42 + float aOpacity = 1.0f); 1.43 + 1.44 + virtual nsresult AttributeChanged(int32_t aNameSpaceID, 1.45 + nsIAtom* aAttribute, 1.46 + int32_t aModType) MOZ_OVERRIDE; 1.47 + 1.48 +#ifdef DEBUG 1.49 + virtual void Init(nsIContent* aContent, 1.50 + nsIFrame* aParent, 1.51 + nsIFrame* aPrevInFlow) MOZ_OVERRIDE; 1.52 +#endif 1.53 + 1.54 + virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, 1.55 + const nsRect& aDirtyRect, 1.56 + const nsDisplayListSet& aLists) MOZ_OVERRIDE {} 1.57 + 1.58 + /** 1.59 + * Get the "type" of the frame 1.60 + * 1.61 + * @see nsGkAtoms::svgMaskFrame 1.62 + */ 1.63 + virtual nsIAtom* GetType() const MOZ_OVERRIDE; 1.64 + 1.65 +#ifdef DEBUG_FRAME_DUMP 1.66 + virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE 1.67 + { 1.68 + return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult); 1.69 + } 1.70 +#endif 1.71 + 1.72 +private: 1.73 + // A helper class to allow us to paint masks safely. The helper 1.74 + // automatically sets and clears the mInUse flag on the mask frame 1.75 + // (to prevent nasty reference loops). It's easy to mess this up 1.76 + // and break things, so this helper makes the code far more robust. 1.77 + class MOZ_STACK_CLASS AutoMaskReferencer 1.78 + { 1.79 + public: 1.80 + AutoMaskReferencer(nsSVGMaskFrame *aFrame 1.81 + MOZ_GUARD_OBJECT_NOTIFIER_PARAM) 1.82 + : mFrame(aFrame) { 1.83 + MOZ_GUARD_OBJECT_NOTIFIER_INIT; 1.84 + NS_ASSERTION(!mFrame->mInUse, "reference loop!"); 1.85 + mFrame->mInUse = true; 1.86 + } 1.87 + ~AutoMaskReferencer() { 1.88 + mFrame->mInUse = false; 1.89 + } 1.90 + private: 1.91 + nsSVGMaskFrame *mFrame; 1.92 + MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER 1.93 + }; 1.94 + 1.95 + nsIFrame *mMaskParent; 1.96 + nsAutoPtr<gfxMatrix> mMaskParentMatrix; 1.97 + // recursion prevention flag 1.98 + bool mInUse; 1.99 + 1.100 + // nsSVGContainerFrame methods: 1.101 + virtual gfxMatrix GetCanvasTM(uint32_t aFor, 1.102 + nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE; 1.103 +}; 1.104 + 1.105 +#endif