2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef __NS_SVGMASKFRAME_H__
|
|
|
|
#define __NS_SVGMASKFRAME_H__
|
|
|
|
|
2007-05-22 12:31:04 -07:00
|
|
|
#include "gfxPattern.h"
|
2009-04-28 21:31:34 -07:00
|
|
|
#include "gfxMatrix.h"
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "nsSVGContainerFrame.h"
|
|
|
|
#include "nsSVGUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class gfxContext;
|
2012-03-02 00:28:59 -08:00
|
|
|
class nsRenderingContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef nsSVGContainerFrame nsSVGMaskFrameBase;
|
|
|
|
|
|
|
|
class nsSVGMaskFrame : public nsSVGMaskFrameBase
|
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-09-07 02:30:51 -07:00
|
|
|
protected:
|
2012-03-10 11:28:06 -08:00
|
|
|
nsSVGMaskFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGMaskFrameBase(aContext)
|
|
|
|
, mInUse(false)
|
|
|
|
{
|
|
|
|
AddStateBits(NS_STATE_SVG_NONDISPLAY_CHILD);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-07 02:30:51 -07:00
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsSVGMaskFrame method:
|
2012-03-02 00:28:59 -08:00
|
|
|
already_AddRefed<gfxPattern> ComputeMaskAlpha(nsRenderingContext *aContext,
|
2008-09-10 17:24:16 -07:00
|
|
|
nsIFrame* aParent,
|
2009-07-23 01:35:59 -07:00
|
|
|
const gfxMatrix &aMatrix,
|
2007-05-22 12:31:04 -07:00
|
|
|
float aOpacity = 1.0f);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-29 07:03:21 -07:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2011-09-19 05:59:52 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType);
|
2011-09-19 05:59:52 -07:00
|
|
|
|
2009-01-19 10:31:34 -08:00
|
|
|
#ifdef DEBUG
|
2013-03-19 18:47:48 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2009-01-19 10:31:34 -08:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
|
2012-07-20 09:41:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgMaskFrame
|
|
|
|
*/
|
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-09-07 02:30:51 -07:00
|
|
|
private:
|
2007-06-21 04:01:41 -07:00
|
|
|
// A helper class to allow us to paint masks safely. The helper
|
|
|
|
// automatically sets and clears the mInUse flag on the mask frame
|
|
|
|
// (to prevent nasty reference loops). It's easy to mess this up
|
|
|
|
// and break things, so this helper makes the code far more robust.
|
|
|
|
class AutoMaskReferencer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoMaskReferencer(nsSVGMaskFrame *aFrame)
|
|
|
|
: mFrame(aFrame) {
|
2010-02-07 07:52:43 -08:00
|
|
|
NS_ASSERTION(!mFrame->mInUse, "reference loop!");
|
2011-10-17 07:59:28 -07:00
|
|
|
mFrame->mInUse = true;
|
2007-06-21 04:01:41 -07:00
|
|
|
}
|
|
|
|
~AutoMaskReferencer() {
|
2011-10-17 07:59:28 -07:00
|
|
|
mFrame->mInUse = false;
|
2007-06-21 04:01:41 -07:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsSVGMaskFrame *mFrame;
|
|
|
|
};
|
|
|
|
|
2008-09-10 17:24:16 -07:00
|
|
|
nsIFrame *mMaskParent;
|
2011-09-25 14:04:32 -07:00
|
|
|
nsAutoPtr<gfxMatrix> mMaskParentMatrix;
|
2007-06-21 04:01:41 -07:00
|
|
|
// recursion prevention flag
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInUse;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual gfxMatrix GetCanvasTM(uint32_t aFor);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|