2006-05-05 20:06:43 +04: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/. */
|
2006-05-05 20:06:43 +04:00
|
|
|
|
|
|
|
#ifndef __NS_SVGPATTERNFRAME_H__
|
|
|
|
#define __NS_SVGPATTERNFRAME_H__
|
|
|
|
|
2013-05-29 23:37:49 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-04-30 19:53:55 +04:00
|
|
|
#include "gfxMatrix.h"
|
2013-10-29 12:14:40 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-06-18 04:07:21 +04:00
|
|
|
#include "mozilla/RefPtr.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "nsSVGPaintServerFrame.h"
|
2006-05-05 20:06:43 +04:00
|
|
|
|
|
|
|
class nsIFrame;
|
2012-03-20 16:15:55 +04:00
|
|
|
class nsSVGLength2;
|
2014-01-04 12:29:02 +04:00
|
|
|
class nsSVGPathGeometryFrame;
|
2012-03-18 14:32:02 +04:00
|
|
|
class nsSVGViewBox;
|
2006-05-05 20:06:43 +04:00
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class SVGAnimatedPreserveAspectRatio;
|
2013-04-15 02:56:34 +04:00
|
|
|
class nsSVGAnimatedTransformList;
|
2010-12-20 03:45:29 +03:00
|
|
|
} // namespace mozilla
|
2010-12-20 03:45:29 +03:00
|
|
|
|
2006-05-16 19:55:01 +04:00
|
|
|
typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
|
2006-05-05 20:06:43 +04:00
|
|
|
|
2008-10-01 04:51:05 +04: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
|
2006-05-05 20:06:43 +04:00
|
|
|
{
|
2014-06-18 04:07:21 +04:00
|
|
|
typedef mozilla::gfx::SourceSurface SourceSurface;
|
|
|
|
|
2006-05-05 20:06:43 +04:00
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2008-10-01 04:51:05 +04:00
|
|
|
friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
|
2006-05-05 20:06:43 +04:00
|
|
|
nsStyleContext* aContext);
|
|
|
|
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsSVGPatternFrame(nsStyleContext* aContext);
|
2006-05-05 20:06:43 +04:00
|
|
|
|
2006-05-16 19:55:01 +04:00
|
|
|
// nsSVGPaintServerFrame methods:
|
2010-07-01 20:40:30 +04:00
|
|
|
virtual already_AddRefed<gfxPattern>
|
|
|
|
GetPaintServerPattern(nsIFrame *aSource,
|
2014-09-29 17:15:19 +04:00
|
|
|
const DrawTarget* aDrawTarget,
|
2012-07-14 03:18:38 +04:00
|
|
|
const gfxMatrix& aContextMatrix,
|
2012-05-18 12:34:25 +04:00
|
|
|
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
2010-07-01 20:40:30 +04:00
|
|
|
float aOpacity,
|
2015-03-21 19:28:04 +03:00
|
|
|
const gfxRect *aOverrideBounds) override;
|
2006-05-16 19:55:01 +04:00
|
|
|
|
2007-04-03 14:52:00 +04:00
|
|
|
public:
|
2010-12-20 03:45:29 +03:00
|
|
|
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
|
|
|
|
|
2006-06-01 19:31:15 +04:00
|
|
|
// nsSVGContainerFrame methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual gfxMatrix GetCanvasTM() override;
|
2006-05-05 20:06:43 +04: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;
|
2006-05-05 20:06:43 +04:00
|
|
|
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
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
|
|
|
#endif
|
|
|
|
|
2006-05-05 20:06:43 +04:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2007-01-30 03:06:41 +03:00
|
|
|
* @see nsGkAtoms::svgPatternFrame
|
2006-05-05 20:06:43 +04:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2006-05-05 20:06:43 +04: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-05-05 20:06:43 +04:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGPattern"), aResult);
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
protected:
|
2008-09-30 15:28:20 +04:00
|
|
|
// Internal methods for handling referenced patterns
|
2011-01-16 10:36:34 +03:00
|
|
|
class AutoPatternReferencer;
|
2008-10-01 04:51:05 +04:00
|
|
|
nsSVGPatternFrame* GetReferencedPattern();
|
2011-01-16 10:36:34 +03:00
|
|
|
nsSVGPatternFrame* GetReferencedPatternIfNotInUse();
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2011-01-16 10:36:34 +03:00
|
|
|
// Accessors to lookup pattern attributes
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t GetEnumValue(uint32_t aIndex, nsIContent *aDefault);
|
|
|
|
uint16_t GetEnumValue(uint32_t aIndex)
|
2011-01-16 10:36:34 +03:00
|
|
|
{
|
|
|
|
return GetEnumValue(aIndex, mContent);
|
|
|
|
}
|
2013-04-15 02:56:34 +04:00
|
|
|
mozilla::nsSVGAnimatedTransformList* GetPatternTransformList(
|
2011-09-26 01:04:32 +04:00
|
|
|
nsIContent* aDefault);
|
2011-01-16 10:36:34 +03: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 19:56:38 +04:00
|
|
|
const nsSVGLength2 *GetLengthValue(uint32_t aIndex, nsIContent *aDefault);
|
|
|
|
const nsSVGLength2 *GetLengthValue(uint32_t aIndex)
|
2011-01-16 10:36:34 +03:00
|
|
|
{
|
|
|
|
return GetLengthValue(aIndex, mContent);
|
|
|
|
}
|
2010-07-01 20:40:30 +04:00
|
|
|
|
2014-06-18 04:07:21 +04:00
|
|
|
mozilla::TemporaryRef<SourceSurface>
|
2014-09-29 17:15:19 +04:00
|
|
|
PaintPattern(const DrawTarget* aDrawTarget,
|
|
|
|
Matrix *patternMatrix,
|
2014-06-18 04:07:21 +04:00
|
|
|
const Matrix &aContextMatrix,
|
|
|
|
nsIFrame *aSource,
|
|
|
|
nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
|
|
|
|
float aGraphicOpacity,
|
|
|
|
const gfxRect *aOverrideBounds);
|
2014-09-30 21:08:14 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A <pattern> element may reference another <pattern> element using
|
|
|
|
* xlink:href and, if it doesn't have any child content of its own, then it
|
|
|
|
* will "inherit" the children of the referenced pattern (which may itself be
|
|
|
|
* inheriting its children if it references another <pattern>). This
|
|
|
|
* function returns this nsSVGPatternFrame or the first pattern along the
|
|
|
|
* reference chain (if there is one) to have children.
|
|
|
|
*/
|
|
|
|
nsSVGPatternFrame* GetPatternWithChildren();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
gfxRect GetPatternRect(uint16_t aPatternUnits,
|
2012-07-31 14:17:11 +04:00
|
|
|
const gfxRect &bbox,
|
2013-10-29 12:14:40 +04:00
|
|
|
const Matrix &callerCTM,
|
2010-07-01 20:40:30 +04:00
|
|
|
nsIFrame *aTarget);
|
2012-07-31 14:17:11 +04:00
|
|
|
gfxMatrix ConstructCTM(const nsSVGViewBox& aViewBox,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t aPatternContentUnits,
|
|
|
|
uint16_t aPatternUnits,
|
2012-07-31 14:17:11 +04:00
|
|
|
const gfxRect &callerBBox,
|
2013-10-29 12:14:40 +04:00
|
|
|
const Matrix &callerCTM,
|
2010-07-01 20:40:30 +04:00
|
|
|
nsIFrame *aTarget);
|
2006-05-05 20:06:43 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
// this is a *temporary* reference to the frame of the element currently
|
2006-09-08 17:54:05 +04:00
|
|
|
// referencing our pattern. This must be temporary because different
|
|
|
|
// referencing frames will all reference this one frame
|
2014-01-04 12:29:02 +04:00
|
|
|
nsSVGPathGeometryFrame *mSource;
|
2011-09-26 01:04:32 +04:00
|
|
|
nsAutoPtr<gfxMatrix> mCTM;
|
2006-05-05 20:06:43 +04:00
|
|
|
|
|
|
|
protected:
|
2008-10-01 04:51:05 +04:00
|
|
|
// This flag is used to detect loops in xlink:href processing
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mLoopFlag;
|
|
|
|
bool mNoHRefURI;
|
2006-05-05 20:06:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|