2005-01-25 06:55:03 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 06:55:03 +03:00
|
|
|
|
2006-01-20 20:00:43 +03:00
|
|
|
#ifndef __NS_SVGCLIPPATHFRAME_H__
|
|
|
|
#define __NS_SVGCLIPPATHFRAME_H__
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2013-05-29 23:37:49 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "gfxMatrix.h"
|
2006-07-21 18:58:57 +04:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-03-18 14:32:02 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2014-10-31 23:08:53 +03:00
|
|
|
class gfxContext;
|
2012-06-15 13:06:34 +04:00
|
|
|
class nsISVGChildFrame;
|
2012-03-02 12:28:59 +04:00
|
|
|
|
2006-07-21 18:58:57 +04:00
|
|
|
typedef nsSVGContainerFrame nsSVGClipPathFrameBase;
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2006-07-21 18:58:57 +04:00
|
|
|
class nsSVGClipPathFrame : public nsSVGClipPathFrameBase
|
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-09-07 13:30:51 +04:00
|
|
|
protected:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsSVGClipPathFrame(nsStyleContext* aContext)
|
2012-03-10 23:28:06 +04:00
|
|
|
: nsSVGClipPathFrameBase(aContext)
|
|
|
|
, mInUse(false)
|
|
|
|
{
|
2013-07-12 11:13:07 +04:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 23:28:06 +04:00
|
|
|
}
|
2006-07-21 18:58:57 +04:00
|
|
|
|
2007-09-07 13:30:51 +04:00
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2012-07-20 20:41:29 +04:00
|
|
|
// nsIFrame methods:
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override {}
|
2012-07-20 20:41:29 +04:00
|
|
|
|
2006-07-21 18:58:57 +04:00
|
|
|
// nsSVGClipPathFrame methods:
|
2014-08-13 16:36:32 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the SVG clipPath is simple (as determined by the IsTrivial() method),
|
|
|
|
* calling this method simply pushes a clip path onto the DrawTarget. If the
|
|
|
|
* SVG clipPath is not simple then calling this method will paint the
|
|
|
|
* clipPath's contents (geometry being filled only, with opaque black) to the
|
|
|
|
* DrawTarget. In this latter case callers are expected to first push a
|
|
|
|
* group before calling this method, then pop the group after calling and use
|
|
|
|
* it as a mask to mask the clipped frame.
|
|
|
|
*
|
|
|
|
* XXXjwatt Maybe split this into two methods.
|
|
|
|
*/
|
2014-10-31 23:08:53 +03:00
|
|
|
nsresult ApplyClipOrPaintClipMask(gfxContext& aContext,
|
2014-08-13 16:36:32 +04:00
|
|
|
nsIFrame* aClippedFrame,
|
|
|
|
const gfxMatrix &aMatrix);
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2014-08-07 11:09:31 +04:00
|
|
|
/**
|
|
|
|
* aPoint is expected to be in aClippedFrame's SVG user space.
|
|
|
|
*/
|
|
|
|
bool PointIsInsideClipPath(nsIFrame* aClippedFrame, const gfxPoint &aPoint);
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2006-01-20 20:00:43 +03: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 18:20:58 +04:00
|
|
|
bool IsTrivial(nsISVGChildFrame **aSingleChild = nullptr);
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsValid();
|
2010-03-02 12:31:07 +03:00
|
|
|
|
2010-03-24 19:54:48 +03:00
|
|
|
// nsIFrame interface:
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
2010-03-24 19:54:48 +03:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2009-01-19 21:31:34 +03:00
|
|
|
|
2006-07-21 18:58:57 +04:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2007-01-30 03:06:41 +03:00
|
|
|
* @see nsGkAtoms::svgClipPathFrame
|
2006-07-21 18:58:57 +04:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override
|
2006-07-21 18:58:57 +04:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGClipPath"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2006-01-20 20:00:43 +03:00
|
|
|
|
2014-05-13 05:24:35 +04:00
|
|
|
SVGBBox
|
|
|
|
GetBBoxForClipPathFrame(const SVGBBox &aBBox, const gfxMatrix &aMatrix);
|
|
|
|
|
2014-08-07 11:09:31 +04:00
|
|
|
/**
|
|
|
|
* If the clipPath element transforms its children due to
|
|
|
|
* clipPathUnits="objectBoundingBox" being set on it and/or due to the
|
|
|
|
* 'transform' attribute being set on it, this function returns the resulting
|
|
|
|
* transform.
|
|
|
|
*/
|
|
|
|
gfxMatrix GetClipPathTransform(nsIFrame* aClippedFrame);
|
|
|
|
|
2006-07-21 18:58:57 +04:00
|
|
|
private:
|
2007-04-17 13:01:52 +04: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 22:49:49 +04:00
|
|
|
class MOZ_STACK_CLASS AutoClipPathReferencer
|
2007-04-17 13:01:52 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit AutoClipPathReferencer(nsSVGClipPathFrame *aFrame
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2007-04-19 12:21:49 +04:00
|
|
|
: mFrame(aFrame) {
|
2013-12-26 22:49:49 +04:00
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
2010-02-07 18:52:43 +03:00
|
|
|
NS_ASSERTION(!mFrame->mInUse, "reference loop!");
|
2011-10-17 18:59:28 +04:00
|
|
|
mFrame->mInUse = true;
|
2007-04-17 13:01:52 +04:00
|
|
|
}
|
|
|
|
~AutoClipPathReferencer() {
|
2011-10-17 18:59:28 +04:00
|
|
|
mFrame->mInUse = false;
|
2007-04-17 13:01:52 +04:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsSVGClipPathFrame *mFrame;
|
2013-12-26 22:49:49 +04:00
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
2007-04-17 13:01:52 +04:00
|
|
|
};
|
|
|
|
|
2014-08-13 16:34:52 +04:00
|
|
|
gfxMatrix mMatrixForChildren;
|
2008-10-01 04:51:05 +04:00
|
|
|
// recursion prevention flag
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInUse;
|
2006-07-21 18:58:57 +04:00
|
|
|
|
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2006-07-21 18:58:57 +04:00
|
|
|
};
|
2005-11-11 17:36:26 +03:00
|
|
|
|
2006-01-20 20:00:43 +03:00
|
|
|
#endif
|