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_SVGCLIPPATHFRAME_H__
|
|
|
|
#define __NS_SVGCLIPPATHFRAME_H__
|
|
|
|
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "gfxMatrix.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-03-18 03:32:02 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-02 00:28:59 -08:00
|
|
|
class nsRenderingContext;
|
2012-06-15 02:06:34 -07:00
|
|
|
class nsISVGChildFrame;
|
2012-03-02 00:28:59 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef nsSVGContainerFrame nsSVGClipPathFrameBase;
|
|
|
|
|
|
|
|
class nsSVGClipPathFrame : public nsSVGClipPathFrameBase
|
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-09-07 02:30:51 -07:00
|
|
|
protected:
|
2012-03-10 11:28:06 -08:00
|
|
|
nsSVGClipPathFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGClipPathFrameBase(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
|
|
|
|
|
2012-07-20 09:41:29 -07:00
|
|
|
// nsIFrame methods:
|
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsSVGClipPathFrame methods:
|
2012-03-02 00:28:59 -08:00
|
|
|
nsresult ClipPaint(nsRenderingContext* aContext,
|
2008-09-10 17:24:16 -07:00
|
|
|
nsIFrame* aParent,
|
2009-07-23 01:35:59 -07:00
|
|
|
const gfxMatrix &aMatrix);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ClipHitTest(nsIFrame* aParent,
|
2009-07-23 01:35:59 -07:00
|
|
|
const gfxMatrix &aMatrix,
|
2008-08-25 02:23:54 -07:00
|
|
|
const nsPoint &aPoint);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Check if this clipPath is made up of more than one geometry object.
|
|
|
|
// If so, the clipping API in cairo isn't enough and we need to use
|
|
|
|
// mask based clipping.
|
2012-07-30 07:20:58 -07:00
|
|
|
bool IsTrivial(nsISVGChildFrame **aSingleChild = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsValid();
|
2010-03-02 01:31:07 -08:00
|
|
|
|
2010-03-24 09:54:48 -07:00
|
|
|
// nsIFrame interface:
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2010-03-24 09:54:48 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType);
|
2010-03-24 09:54:48 -07:00
|
|
|
|
2009-01-19 10:31:34 -08:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgClipPathFrame
|
|
|
|
*/
|
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGClipPath"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
2007-04-17 02:01:52 -07:00
|
|
|
// A helper class to allow us to paint clip paths safely. The helper
|
|
|
|
// automatically sets and clears the mInUse flag on the clip path 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 AutoClipPathReferencer
|
|
|
|
{
|
|
|
|
public:
|
2007-04-19 01:21:49 -07:00
|
|
|
AutoClipPathReferencer(nsSVGClipPathFrame *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-04-17 02:01:52 -07:00
|
|
|
}
|
|
|
|
~AutoClipPathReferencer() {
|
2011-10-17 07:59:28 -07:00
|
|
|
mFrame->mInUse = false;
|
2007-04-17 02:01:52 -07:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsSVGClipPathFrame *mFrame;
|
|
|
|
};
|
|
|
|
|
2008-09-10 17:24:16 -07:00
|
|
|
nsIFrame *mClipParent;
|
2011-09-25 14:04:32 -07:00
|
|
|
nsAutoPtr<gfxMatrix> mClipParentMatrix;
|
2008-09-30 17:51:05 -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
|