2006-01-20 17:00:43 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-01-20 17:00:43 +00:00
|
|
|
|
|
|
|
#ifndef __NS_SVGMASKFRAME_H__
|
|
|
|
#define __NS_SVGMASKFRAME_H__
|
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-05-22 19:31:04 +00:00
|
|
|
#include "gfxPattern.h"
|
2009-04-29 04:31:34 +00:00
|
|
|
#include "gfxMatrix.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsSVGContainerFrame.h"
|
|
|
|
#include "nsSVGUtils.h"
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2006-11-27 17:30:57 +00:00
|
|
|
class gfxContext;
|
2012-03-02 08:28:59 +00:00
|
|
|
class nsRenderingContext;
|
2006-11-27 17:30:57 +00:00
|
|
|
|
2006-07-25 18:29:10 +00:00
|
|
|
typedef nsSVGContainerFrame nsSVGMaskFrameBase;
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2014-06-23 04:45:31 +00:00
|
|
|
class nsSVGMaskFrame MOZ_FINAL : public nsSVGMaskFrameBase
|
2006-07-25 18:29:10 +00:00
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 18:31:34 +00:00
|
|
|
NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-09-07 09:30:51 +00:00
|
|
|
protected:
|
2012-03-10 19:28:06 +00:00
|
|
|
nsSVGMaskFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGMaskFrameBase(aContext)
|
|
|
|
, mInUse(false)
|
|
|
|
{
|
2013-07-12 07:13:07 +00:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 19:28:06 +00:00
|
|
|
}
|
2006-07-25 18:29:10 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2006-07-25 18:29:10 +00:00
|
|
|
// nsSVGMaskFrame method:
|
2014-06-23 04:45:31 +00:00
|
|
|
already_AddRefed<gfxPattern> GetMaskForMaskedFrame(gfxContext* aContext,
|
|
|
|
nsIFrame* aMaskedFrame,
|
|
|
|
const gfxMatrix &aMatrix,
|
|
|
|
float aOpacity);
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 08:36:33 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2011-09-19 12:59:52 +00:00
|
|
|
|
2009-01-19 18:31:34 +00:00
|
|
|
#ifdef DEBUG
|
2014-05-24 22:20:40 +00:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2009-01-19 18:31:34 +00:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
|
2012-07-20 16:41:29 +00:00
|
|
|
|
2006-07-25 18:29:10 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2007-01-30 00:06:41 +00:00
|
|
|
* @see nsGkAtoms::svgMaskFrame
|
2006-07-25 18:29:10 +00:00
|
|
|
*/
|
2013-05-29 19:37:49 +00:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2006-07-25 18:29:10 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
|
2006-07-25 18:29:10 +00:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGMask"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
private:
|
2007-06-21 11:01:41 +00: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.
|
2013-12-26 18:49:49 +00:00
|
|
|
class MOZ_STACK_CLASS AutoMaskReferencer
|
2007-06-21 11:01:41 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-12-26 18:49:49 +00:00
|
|
|
AutoMaskReferencer(nsSVGMaskFrame *aFrame
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2007-06-21 11:01:41 +00:00
|
|
|
: mFrame(aFrame) {
|
2013-12-26 18:49:49 +00:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
2010-02-07 15:52:43 +00:00
|
|
|
NS_ASSERTION(!mFrame->mInUse, "reference loop!");
|
2011-10-17 14:59:28 +00:00
|
|
|
mFrame->mInUse = true;
|
2007-06-21 11:01:41 +00:00
|
|
|
}
|
|
|
|
~AutoMaskReferencer() {
|
2011-10-17 14:59:28 +00:00
|
|
|
mFrame->mInUse = false;
|
2007-06-21 11:01:41 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsSVGMaskFrame *mFrame;
|
2013-12-26 18:49:49 +00:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2007-06-21 11:01:41 +00:00
|
|
|
};
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
nsIFrame *mMaskParent;
|
2011-09-25 21:04:32 +00:00
|
|
|
nsAutoPtr<gfxMatrix> mMaskParentMatrix;
|
2007-06-21 11:01:41 +00:00
|
|
|
// recursion prevention flag
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInUse;
|
2006-07-25 18:29:10 +00:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2013-09-11 07:27:45 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM(uint32_t aFor,
|
|
|
|
nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
|
2006-07-25 18:29:10 +00:00
|
|
|
};
|
2006-01-20 17:00:43 +00:00
|
|
|
|
|
|
|
#endif
|