2005-01-25 03:55:03 +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/. */
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2006-01-20 17:00:43 +00:00
|
|
|
#ifndef __NS_SVGCLIPPATHFRAME_H__
|
|
|
|
#define __NS_SVGCLIPPATHFRAME_H__
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "gfxMatrix.h"
|
2006-07-21 14:58:57 +00:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-03-18 10:32:02 +00:00
|
|
|
#include "nsSVGUtils.h"
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2012-03-02 08:28:59 +00:00
|
|
|
class nsRenderingContext;
|
2012-06-15 09:06:34 +00:00
|
|
|
class nsISVGChildFrame;
|
2012-03-02 08:28:59 +00:00
|
|
|
|
2006-07-21 14:58:57 +00:00
|
|
|
typedef nsSVGContainerFrame nsSVGClipPathFrameBase;
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2006-07-21 14:58:57 +00:00
|
|
|
class nsSVGClipPathFrame : public nsSVGClipPathFrameBase
|
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 18:31:34 +00:00
|
|
|
NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-09-07 09:30:51 +00:00
|
|
|
protected:
|
2012-03-10 19:28:06 +00:00
|
|
|
nsSVGClipPathFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGClipPathFrameBase(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-21 14:58:57 +00:00
|
|
|
|
2007-09-07 09:30:51 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2012-07-20 16:41:29 +00:00
|
|
|
// nsIFrame methods:
|
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-21 14:58:57 +00:00
|
|
|
// nsSVGClipPathFrame methods:
|
2012-03-02 08:28:59 +00:00
|
|
|
nsresult ClipPaint(nsRenderingContext* aContext,
|
2008-09-11 00:24:16 +00:00
|
|
|
nsIFrame* aParent,
|
2009-07-23 08:35:59 +00:00
|
|
|
const gfxMatrix &aMatrix);
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool ClipHitTest(nsIFrame* aParent,
|
2009-07-23 08:35:59 +00:00
|
|
|
const gfxMatrix &aMatrix,
|
2008-08-25 09:23:54 +00:00
|
|
|
const nsPoint &aPoint);
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2006-01-20 17:00:43 +00: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 14:20:58 +00:00
|
|
|
bool IsTrivial(nsISVGChildFrame **aSingleChild = nullptr);
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsValid();
|
2010-03-02 09:31:07 +00:00
|
|
|
|
2010-03-24 16:54:48 +00:00
|
|
|
// nsIFrame interface:
|
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;
|
2010-03-24 16:54:48 +00:00
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2009-01-19 18:31:34 +00:00
|
|
|
|
2006-07-21 14:58:57 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2007-01-30 00:06:41 +00:00
|
|
|
* @see nsGkAtoms::svgClipPathFrame
|
2006-07-21 14:58:57 +00:00
|
|
|
*/
|
2013-05-29 19:37:49 +00:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2005-01-25 03:55:03 +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-21 14:58:57 +00:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGClipPath"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2006-01-20 17:00:43 +00:00
|
|
|
|
2006-07-21 14:58:57 +00:00
|
|
|
private:
|
2007-04-17 09:01:52 +00: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.
|
2013-12-26 18:49:49 +00:00
|
|
|
class MOZ_STACK_CLASS AutoClipPathReferencer
|
2007-04-17 09:01:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-12-26 18:49:49 +00:00
|
|
|
AutoClipPathReferencer(nsSVGClipPathFrame *aFrame
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2007-04-19 08:21:49 +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-04-17 09:01:52 +00:00
|
|
|
}
|
|
|
|
~AutoClipPathReferencer() {
|
2011-10-17 14:59:28 +00:00
|
|
|
mFrame->mInUse = false;
|
2007-04-17 09:01:52 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsSVGClipPathFrame *mFrame;
|
2013-12-26 18:49:49 +00:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2007-04-17 09:01:52 +00:00
|
|
|
};
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
nsIFrame *mClipParent;
|
2011-09-25 21:04:32 +00:00
|
|
|
nsAutoPtr<gfxMatrix> mClipParentMatrix;
|
2008-10-01 00:51:05 +00:00
|
|
|
// recursion prevention flag
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInUse;
|
2006-07-21 14:58:57 +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-21 14:58:57 +00:00
|
|
|
};
|
2005-11-11 14:36:26 +00:00
|
|
|
|
2006-01-20 17:00:43 +00:00
|
|
|
#endif
|