2006-05-05 16:06:43 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Mozilla SVG project.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Scooter Morris.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Scooter Morris <scootermorris@comcast.net>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef __NS_SVGPATTERNFRAME_H__
|
|
|
|
#define __NS_SVGPATTERNFRAME_H__
|
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
#include "nsSVGPaintServerFrame.h"
|
2007-04-30 15:53:55 +00:00
|
|
|
#include "gfxMatrix.h"
|
2011-08-11 13:29:50 +00:00
|
|
|
#include "nsIDOMSVGAnimTransformList.h"
|
2006-05-05 16:06:43 +00:00
|
|
|
|
|
|
|
class nsIFrame;
|
|
|
|
class nsSVGLength2;
|
|
|
|
class nsSVGElement;
|
2006-11-27 17:30:57 +00:00
|
|
|
class gfxContext;
|
2007-04-30 15:53:55 +00:00
|
|
|
class gfxASurface;
|
2006-05-05 16:06:43 +00:00
|
|
|
|
2010-12-20 00:45:29 +00:00
|
|
|
namespace mozilla {
|
|
|
|
class SVGAnimatedPreserveAspectRatio;
|
2011-09-25 21:04:32 +00:00
|
|
|
class SVGAnimatedTransformList;
|
2010-12-20 00:45:29 +00:00
|
|
|
} // namespace mozilla
|
2010-12-20 00:45:29 +00:00
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
|
2006-05-05 16:06:43 +00:00
|
|
|
|
2008-10-01 00:51:05 +00: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 16:06:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
|
2006-05-05 16:06:43 +00:00
|
|
|
nsStyleContext* aContext);
|
|
|
|
|
2008-10-11 11:29:35 +00:00
|
|
|
nsSVGPatternFrame(nsStyleContext* aContext);
|
2006-05-05 16:06:43 +00:00
|
|
|
|
2006-05-16 15:55:01 +00:00
|
|
|
// nsSVGPaintServerFrame methods:
|
2010-07-01 16:40:30 +00:00
|
|
|
virtual already_AddRefed<gfxPattern>
|
|
|
|
GetPaintServerPattern(nsIFrame *aSource,
|
|
|
|
float aOpacity,
|
|
|
|
const gfxRect *aOverrideBounds);
|
2006-05-16 15:55:01 +00:00
|
|
|
|
2007-04-03 10:52:00 +00:00
|
|
|
public:
|
2010-12-20 00:45:29 +00:00
|
|
|
typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
// nsSVGContainerFrame methods:
|
2009-04-29 04:31:34 +00:00
|
|
|
virtual gfxMatrix GetCanvasTM();
|
2006-05-05 16:06:43 +00:00
|
|
|
|
|
|
|
// nsIFrame interface:
|
2008-10-26 10:11:34 +00:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
|
2006-05-05 16:06:43 +00:00
|
|
|
|
|
|
|
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType);
|
|
|
|
|
2009-01-19 18:31:34 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
#endif
|
|
|
|
|
2006-05-05 16:06:43 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
2007-01-30 00:06:41 +00:00
|
|
|
* @see nsGkAtoms::svgPatternFrame
|
2006-05-05 16:06:43 +00:00
|
|
|
*/
|
|
|
|
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 11:28:20 +00:00
|
|
|
// Internal methods for handling referenced patterns
|
2011-01-16 07:36:34 +00:00
|
|
|
class AutoPatternReferencer;
|
2008-10-01 00:51:05 +00:00
|
|
|
nsSVGPatternFrame* GetReferencedPattern();
|
2011-01-16 07:36:34 +00:00
|
|
|
nsSVGPatternFrame* GetReferencedPatternIfNotInUse();
|
2009-01-05 01:19:38 +00:00
|
|
|
|
2011-01-16 07:36:34 +00:00
|
|
|
// Accessors to lookup pattern attributes
|
|
|
|
PRUint16 GetEnumValue(PRUint32 aIndex, nsIContent *aDefault);
|
|
|
|
PRUint16 GetEnumValue(PRUint32 aIndex)
|
|
|
|
{
|
|
|
|
return GetEnumValue(aIndex, mContent);
|
|
|
|
}
|
2011-09-25 21:04:32 +00:00
|
|
|
mozilla::SVGAnimatedTransformList* GetPatternTransformList(
|
|
|
|
nsIContent* aDefault);
|
2011-01-16 07:36:34 +00: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);
|
|
|
|
}
|
|
|
|
const nsSVGLength2 *GetLengthValue(PRUint32 aIndex, nsIContent *aDefault);
|
|
|
|
const nsSVGLength2 *GetLengthValue(PRUint32 aIndex)
|
|
|
|
{
|
|
|
|
return GetLengthValue(aIndex, mContent);
|
|
|
|
}
|
2010-07-01 16:40:30 +00:00
|
|
|
|
|
|
|
nsresult PaintPattern(gfxASurface **surface,
|
|
|
|
gfxMatrix *patternMatrix,
|
|
|
|
nsIFrame *aSource,
|
|
|
|
float aGraphicOpacity,
|
|
|
|
const gfxRect *aOverrideBounds);
|
2006-05-05 16:06:43 +00:00
|
|
|
NS_IMETHOD GetPatternFirstChild(nsIFrame **kid);
|
2009-06-11 15:21:03 +00:00
|
|
|
gfxRect GetPatternRect(const gfxRect &bbox,
|
2009-07-23 08:35:59 +00:00
|
|
|
const gfxMatrix &callerCTM,
|
2010-07-01 16:40:30 +00:00
|
|
|
nsIFrame *aTarget);
|
2011-10-27 08:51:46 +00:00
|
|
|
gfxMatrix GetPatternMatrix(const gfxMatrix &patternTransform,
|
|
|
|
const gfxRect &bbox,
|
2009-06-11 15:21:03 +00:00
|
|
|
const gfxRect &callerBBox,
|
2009-07-23 08:35:59 +00:00
|
|
|
const gfxMatrix &callerCTM);
|
|
|
|
gfxMatrix ConstructCTM(const gfxRect &callerBBox,
|
2009-10-25 13:05:33 +00:00
|
|
|
const gfxMatrix &callerCTM,
|
2010-07-01 16:40:30 +00:00
|
|
|
nsIFrame *aTarget);
|
2009-07-23 08:35:59 +00:00
|
|
|
nsresult GetTargetGeometry(gfxMatrix *aCTM,
|
2009-06-11 15:21:03 +00:00
|
|
|
gfxRect *aBBox,
|
2010-07-01 16:40:30 +00:00
|
|
|
nsIFrame *aTarget,
|
|
|
|
const gfxRect *aOverrideBounds);
|
2006-05-05 16:06:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// this is a *temporary* reference to the frame of the element currently
|
2006-09-08 13:54:05 +00:00
|
|
|
// referencing our pattern. This must be temporary because different
|
|
|
|
// referencing frames will all reference this one frame
|
2008-10-01 00:51:05 +00:00
|
|
|
nsSVGGeometryFrame *mSource;
|
2011-09-25 21:04:32 +00:00
|
|
|
nsAutoPtr<gfxMatrix> mCTM;
|
2006-05-05 16:06:43 +00:00
|
|
|
|
|
|
|
protected:
|
2008-10-01 00:51:05 +00:00
|
|
|
// This flag is used to detect loops in xlink:href processing
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mLoopFlag;
|
|
|
|
bool mNoHRefURI;
|
2006-05-05 16:06:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|