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_SVGPATTERNFRAME_H__
|
|
|
|
#define __NS_SVGPATTERNFRAME_H__
|
|
|
|
|
2007-04-30 08:53:55 -07:00
|
|
|
#include "gfxMatrix.h"
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "nsSVGPaintServerFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-20 05:15:55 -07:00
|
|
|
class gfxASurface;
|
|
|
|
class gfxContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIFrame;
|
|
|
|
class nsSVGElement;
|
2012-03-20 05:15:55 -07:00
|
|
|
class nsSVGLength2;
|
2012-03-18 03:32:02 -07:00
|
|
|
class nsSVGViewBox;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-12-19 16:45:29 -08:00
|
|
|
namespace mozilla {
|
|
|
|
class SVGAnimatedPreserveAspectRatio;
|
2013-04-14 15:56:34 -07:00
|
|
|
class nsSVGAnimatedTransformList;
|
2010-12-19 16:45:29 -08:00
|
|
|
} // namespace mozilla
|
2010-12-19 16:45:29 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
|
|
|
|
|
2008-09-30 17:51:05 -07:00
|
|
|
/**
|
|
|
|
* Patterns can refer to other patterns. We create an nsSVGPaintingProperty
|
|
|
|
* with property type nsGkAtoms::href to track the referenced pattern.
|
|
|
|
*/
|
|
|
|
class nsSVGPatternFrame : public nsSVGPatternFrameBase
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2008-09-30 17:51:05 -07:00
|
|
|
friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleContext* aContext);
|
|
|
|
|
2008-10-11 04:29:35 -07:00
|
|
|
nsSVGPatternFrame(nsStyleContext* aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsSVGPaintServerFrame methods:
|
2010-07-01 09:40:30 -07:00
|
|
|
virtual already_AddRefed<gfxPattern>
|
|
|
|
GetPaintServerPattern(nsIFrame *aSource,
|
2012-07-13 16:18:38 -07:00
|
|
|
const gfxMatrix& aContextMatrix,
|
2012-05-18 01:34:25 -07:00
|
|
|
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
2010-07-01 09:40:30 -07:00
|
|
|
float aOpacity,
|
|
|
|
const gfxRect *aOverrideBounds);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-03 03:52:00 -07:00
|
|
|
public:
|
2010-12-19 16:45:29 -08:00
|
|
|
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
|
|
|
|
|
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
|
|
|
|
|
|
|
// nsIFrame interface:
|
2008-10-26 03:11:34 -07:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType);
|
2007-03-22 10:30:00 -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
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsGkAtoms::svgPatternFrame
|
|
|
|
*/
|
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGPattern"), aResult);
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
protected:
|
2008-09-30 04:28:20 -07:00
|
|
|
// Internal methods for handling referenced patterns
|
2011-01-15 23:36:34 -08:00
|
|
|
class AutoPatternReferencer;
|
2008-09-30 17:51:05 -07:00
|
|
|
nsSVGPatternFrame* GetReferencedPattern();
|
2011-01-15 23:36:34 -08:00
|
|
|
nsSVGPatternFrame* GetReferencedPatternIfNotInUse();
|
2009-01-04 17:19:38 -08:00
|
|
|
|
2011-01-15 23:36:34 -08:00
|
|
|
// Accessors to lookup pattern attributes
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t GetEnumValue(uint32_t aIndex, nsIContent *aDefault);
|
|
|
|
uint16_t GetEnumValue(uint32_t aIndex)
|
2011-01-15 23:36:34 -08:00
|
|
|
{
|
|
|
|
return GetEnumValue(aIndex, mContent);
|
|
|
|
}
|
2013-04-14 15:56:34 -07:00
|
|
|
mozilla::nsSVGAnimatedTransformList* GetPatternTransformList(
|
2011-09-25 14:04:32 -07:00
|
|
|
nsIContent* aDefault);
|
2011-01-15 23:36:34 -08:00
|
|
|
gfxMatrix GetPatternTransform();
|
|
|
|
const nsSVGViewBox &GetViewBox(nsIContent *aDefault);
|
|
|
|
const nsSVGViewBox &GetViewBox() { return GetViewBox(mContent); }
|
|
|
|
const SVGAnimatedPreserveAspectRatio &GetPreserveAspectRatio(
|
|
|
|
nsIContent *aDefault);
|
|
|
|
const SVGAnimatedPreserveAspectRatio &GetPreserveAspectRatio()
|
|
|
|
{
|
|
|
|
return GetPreserveAspectRatio(mContent);
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
const nsSVGLength2 *GetLengthValue(uint32_t aIndex, nsIContent *aDefault);
|
|
|
|
const nsSVGLength2 *GetLengthValue(uint32_t aIndex)
|
2011-01-15 23:36:34 -08:00
|
|
|
{
|
|
|
|
return GetLengthValue(aIndex, mContent);
|
|
|
|
}
|
2010-07-01 09:40:30 -07:00
|
|
|
|
|
|
|
nsresult PaintPattern(gfxASurface **surface,
|
|
|
|
gfxMatrix *patternMatrix,
|
2012-07-13 16:18:38 -07:00
|
|
|
const gfxMatrix &aContextMatrix,
|
2010-07-01 09:40:30 -07:00
|
|
|
nsIFrame *aSource,
|
2012-05-18 01:34:25 -07:00
|
|
|
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
2010-07-01 09:40:30 -07:00
|
|
|
float aGraphicOpacity,
|
|
|
|
const gfxRect *aOverrideBounds);
|
2011-10-27 15:57:10 -07:00
|
|
|
nsIFrame* GetPatternFirstChild();
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxRect GetPatternRect(uint16_t aPatternUnits,
|
2012-07-31 03:17:11 -07:00
|
|
|
const gfxRect &bbox,
|
2009-07-23 01:35:59 -07:00
|
|
|
const gfxMatrix &callerCTM,
|
2010-07-01 09:40:30 -07:00
|
|
|
nsIFrame *aTarget);
|
2012-07-31 03:17:11 -07:00
|
|
|
gfxMatrix ConstructCTM(const nsSVGViewBox& aViewBox,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t aPatternContentUnits,
|
|
|
|
uint16_t aPatternUnits,
|
2012-07-31 03:17:11 -07:00
|
|
|
const gfxRect &callerBBox,
|
2009-10-25 06:05:33 -07:00
|
|
|
const gfxMatrix &callerCTM,
|
2010-07-01 09:40:30 -07:00
|
|
|
nsIFrame *aTarget);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// this is a *temporary* reference to the frame of the element currently
|
|
|
|
// referencing our pattern. This must be temporary because different
|
|
|
|
// referencing frames will all reference this one frame
|
2008-09-30 17:51:05 -07:00
|
|
|
nsSVGGeometryFrame *mSource;
|
2011-09-25 14:04:32 -07:00
|
|
|
nsAutoPtr<gfxMatrix> mCTM;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
2008-09-30 17:51:05 -07:00
|
|
|
// This flag is used to detect loops in xlink:href processing
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mLoopFlag;
|
|
|
|
bool mNoHRefURI;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|