Public Types | Static Public Member Functions

nsSVGUtils Class Reference

#include <nsSVGUtils.h>

List of all members.

Public Types

enum  ctxDirection { X, Y, XY }
typedef
mozilla::SVGAnimatedPreserveAspectRatio 
SVGAnimatedPreserveAspectRatio
typedef
mozilla::SVGPreserveAspectRatio 
SVGPreserveAspectRatio

Static Public Member Functions

static mozilla::dom::ElementGetParentElement (nsIContent *aContent)
static float GetFontSize (mozilla::dom::Element *aElement)
static float GetFontSize (nsIFrame *aFrame)
static float GetFontSize (nsStyleContext *aStyleContext)
static float GetFontXHeight (mozilla::dom::Element *aElement)
static float GetFontXHeight (nsIFrame *aFrame)
static float GetFontXHeight (nsStyleContext *aStyleContext)
static void UnPremultiplyImageDataAlpha (PRUint8 *data, PRInt32 stride, const nsIntRect &rect)
static void PremultiplyImageDataAlpha (PRUint8 *data, PRInt32 stride, const nsIntRect &rect)
static void ConvertImageDataToLinearRGB (PRUint8 *data, PRInt32 stride, const nsIntRect &rect)
static void ConvertImageDataFromLinearRGB (PRUint8 *data, PRInt32 stride, const nsIntRect &rect)
static nsresult ReportToConsole (nsIDocument *doc, const char *aWarning, const PRUnichar **aParams, PRUint32 aParamsLength)
static float CoordToFloat (nsPresContext *aPresContext, nsSVGElement *aContent, const nsStyleCoord &aCoord)
static gfxMatrix GetCTM (nsSVGElement *aElement, PRBool aScreenCTM)
static PRBool EstablishesViewport (nsIContent *aContent)
 Check if this is one of the SVG elements that SVG 1.1 Full says establishes a viewport: svg, symbol, image or foreignObject.
static already_AddRefed
< nsIDOMSVGElement
GetNearestViewportElement (nsIContent *aContent)
static already_AddRefed
< nsIDOMSVGElement
GetFarthestViewportElement (nsIContent *aContent)
static nsSVGDisplayContainerFrame * GetNearestSVGViewport (nsIFrame *aFrame)
 Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame.
static nsRect FindFilterInvalidation (nsIFrame *aFrame, const nsRect &aRect)
 Figures out the worst case invalidation area for a frame, taking filters into account.
static void InvalidateCoveredRegion (nsIFrame *aFrame)
 Invalidates the area covered by the frame.
static void UpdateGraphic (nsISVGChildFrame *aSVGFrame)
static void NotifyAncestorsOfFilterRegionChange (nsIFrame *aFrame)
static double ComputeNormalizedHypotenuse (double aWidth, double aHeight)
 Computes sqrt((aWidth^2 + aHeight^2)/2);.
static float ObjectSpace (const gfxRect &aRect, const nsSVGLength2 *aLength)
static float UserSpace (nsSVGElement *aSVGElement, const nsSVGLength2 *aLength)
static float UserSpace (nsIFrame *aFrame, const nsSVGLength2 *aLength)
static float AngleBisect (float a1, float a2)
static nsSVGOuterSVGFrame * GetOuterSVGFrame (nsIFrame *aFrame)
static nsIFrame * GetOuterSVGFrameAndCoveredRegion (nsIFrame *aFrame, nsRect *aRect)
 Get the covered region for a frame.
static gfxMatrix GetViewBoxTransform (nsSVGElement *aElement, float aViewportWidth, float aViewportHeight, float aViewboxX, float aViewboxY, float aViewboxWidth, float aViewboxHeight, const SVGAnimatedPreserveAspectRatio &aPreserveAspectRatio)
static gfxMatrix GetViewBoxTransform (nsSVGElement *aElement, float aViewportWidth, float aViewportHeight, float aViewboxX, float aViewboxY, float aViewboxWidth, float aViewboxHeight, const SVGPreserveAspectRatio &aPreserveAspectRatio)
static void PaintFrameWithEffects (nsSVGRenderState *aContext, const nsIntRect *aDirtyRect, nsIFrame *aFrame)
static PRBool HitTestClip (nsIFrame *aFrame, const nsPoint &aPoint)
static nsIFrame * HitTestChildren (nsIFrame *aFrame, const nsPoint &aPoint)
static gfxMatrix GetCanvasTM (nsIFrame *aFrame)
static void NotifyChildrenOfSVGChange (nsIFrame *aFrame, PRUint32 aFlags)
static nsRect GetCoveredRegion (const nsFrameList &aFrames)
static nsRect ToAppPixelRect (nsPresContext *aPresContext, double xmin, double ymin, double xmax, double ymax)
static nsRect ToAppPixelRect (nsPresContext *aPresContext, const gfxRect &rect)
static gfxIntSize ConvertToSurfaceSize (const gfxSize &aSize, PRBool *aResultOverflows)
static gfxMatrix ConvertSVGMatrixToThebes (nsIDOMSVGMatrix *aMatrix)
static PRBool HitTestRect (const gfxMatrix &aMatrix, float aRX, float aRY, float aRWidth, float aRHeight, float aX, float aY)
static gfxRect GetClipRectForFrame (nsIFrame *aFrame, float aX, float aY, float aWidth, float aHeight)
 Get the clip rect for the given frame, taking into account the CSS 'clip' property.
static void CompositeSurfaceMatrix (gfxContext *aContext, gfxASurface *aSurface, const gfxMatrix &aCTM, float aOpacity)
static void CompositePatternMatrix (gfxContext *aContext, gfxPattern *aPattern, const gfxMatrix &aCTM, float aWidth, float aHeight, float aOpacity)
static void SetClipRect (gfxContext *aContext, const gfxMatrix &aCTM, const gfxRect &aRect)
static void ClipToGfxRect (nsIntRect *aRect, const gfxRect &aGfxRect)
 Restricts aRect to pixels that intersect aGfxRect.
static PRBool CanOptimizeOpacity (nsIFrame *aFrame)
static float MaxExpansion (const gfxMatrix &aMatrix)
static gfxMatrix AdjustMatrixForUnits (const gfxMatrix &aMatrix, nsSVGEnum *aUnits, nsIFrame *aFrame)
 Take the CTM to userspace for an element, and adjust it to a CTM to its object bounding box space if aUnits is SVG_UNIT_TYPE_OBJECTBOUNDINGBOX.
static gfxRect GetBBox (nsIFrame *aFrame)
 Get bounding-box for aFrame.
static gfxRect GetRelativeRect (PRUint16 aUnits, const nsSVGLength2 *aXYWH, const gfxRect &aBBox, nsIFrame *aFrame)
 Compute a rectangle in userSpaceOnUse or objectBoundingBoxUnits.
static nsIFrame * GetFirstNonAAncestorFrame (nsIFrame *aStartFrame)
 Find the first frame, starting with aStartFrame and going up its parent chain, that is not an svgAFrame.
static gfxRect PathExtentsToMaxStrokeExtents (const gfxRect &aPathExtents, nsSVGGeometryFrame *aFrame)
 Compute the maximum possible device space stroke extents of a path given the path's device space path extents, its stroke style and its ctm.
static PRBool IsInnerSVG (nsIContent *aContent)
 Returns true if aContent is an SVG <svg> element that is the child of another non-foreignObject SVG element.
static PRInt32 ClampToInt (double aVal)
 Convert a floating-point value to a 32-bit integer value, clamping to the range of valid integers.
static PRBool RootSVGElementHasViewbox (const nsIContent *aRootSVGElem)
 Given a nsIContent* that is actually an nsSVGSVGElement*, this method checks whether it currently has a valid viewBox, and returns true if so.

Member Typedef Documentation

typedef mozilla::SVGAnimatedPreserveAspectRatio nsSVGUtils::SVGAnimatedPreserveAspectRatio
typedef mozilla::SVGPreserveAspectRatio nsSVGUtils::SVGPreserveAspectRatio

Member Enumeration Documentation

Enumerator:
X 
Y 
XY 

Member Function Documentation

static gfxMatrix nsSVGUtils::AdjustMatrixForUnits ( const gfxMatrix aMatrix,
nsSVGEnum *  aUnits,
nsIFrame *  aFrame 
) [static]

Take the CTM to userspace for an element, and adjust it to a CTM to its object bounding box space if aUnits is SVG_UNIT_TYPE_OBJECTBOUNDINGBOX.

(I.e. so that [0,0] is at the top left of its bbox, and [1,1] is at the bottom right of its bbox).

If the bbox is empty, this will return a singular matrix.

static float nsSVGUtils::AngleBisect ( float  a1,
float  a2 
) [static]
static PRBool nsSVGUtils::CanOptimizeOpacity ( nsIFrame *  aFrame  )  [static]
static PRInt32 nsSVGUtils::ClampToInt ( double  aVal  )  [inline, static]

Convert a floating-point value to a 32-bit integer value, clamping to the range of valid integers.

static void nsSVGUtils::ClipToGfxRect ( nsIntRect aRect,
const gfxRect aGfxRect 
) [static]

Restricts aRect to pixels that intersect aGfxRect.

static void nsSVGUtils::CompositePatternMatrix ( gfxContext aContext,
gfxPattern aPattern,
const gfxMatrix aCTM,
float  aWidth,
float  aHeight,
float  aOpacity 
) [static]
static void nsSVGUtils::CompositeSurfaceMatrix ( gfxContext aContext,
gfxASurface aSurface,
const gfxMatrix aCTM,
float  aOpacity 
) [static]
static double nsSVGUtils::ComputeNormalizedHypotenuse ( double  aWidth,
double  aHeight 
) [static]

Computes sqrt((aWidth^2 + aHeight^2)/2);.

static void nsSVGUtils::ConvertImageDataFromLinearRGB ( PRUint8 *  data,
PRInt32  stride,
const nsIntRect rect 
) [static]
static void nsSVGUtils::ConvertImageDataToLinearRGB ( PRUint8 *  data,
PRInt32  stride,
const nsIntRect rect 
) [static]
static gfxMatrix nsSVGUtils::ConvertSVGMatrixToThebes ( nsIDOMSVGMatrix aMatrix  )  [static]
static gfxIntSize nsSVGUtils::ConvertToSurfaceSize ( const gfxSize aSize,
PRBool aResultOverflows 
) [inline, static]
static float nsSVGUtils::CoordToFloat ( nsPresContext aPresContext,
nsSVGElement *  aContent,
const nsStyleCoord aCoord 
) [static]
static PRBool nsSVGUtils::EstablishesViewport ( nsIContent *  aContent  )  [static]

Check if this is one of the SVG elements that SVG 1.1 Full says establishes a viewport: svg, symbol, image or foreignObject.

static nsRect nsSVGUtils::FindFilterInvalidation ( nsIFrame *  aFrame,
const nsRect aRect 
) [static]

Figures out the worst case invalidation area for a frame, taking filters into account.

Note that the caller is responsible for making sure that any cached covered regions in the frame tree rooted at aFrame are up to date.

Parameters:
aRect the area in app units that needs to be invalidated in aFrame
Returns:
the rect in app units that should be invalidated, taking filters into account. Will return aRect when no filters are present.
static gfxRect nsSVGUtils::GetBBox ( nsIFrame *  aFrame  )  [static]

Get bounding-box for aFrame.

Matrix propagation is disabled so the bounding box is computed in terms of aFrame's own user space.

static gfxMatrix nsSVGUtils::GetCanvasTM ( nsIFrame *  aFrame  )  [static]
static gfxRect nsSVGUtils::GetClipRectForFrame ( nsIFrame *  aFrame,
float  aX,
float  aY,
float  aWidth,
float  aHeight 
) [static]

Get the clip rect for the given frame, taking into account the CSS 'clip' property.

See: http://www.w3.org/TR/SVG11/masking.html#OverflowAndClipProperties The arguments for aX, aY, aWidth and aHeight should be the dimensions of the viewport established by aFrame.

static nsRect nsSVGUtils::GetCoveredRegion ( const nsFrameList aFrames  )  [static]
static gfxMatrix nsSVGUtils::GetCTM ( nsSVGElement *  aElement,
PRBool  aScreenCTM 
) [static]
static already_AddRefed<nsIDOMSVGElement> nsSVGUtils::GetFarthestViewportElement ( nsIContent *  aContent  )  [static]
static nsIFrame* nsSVGUtils::GetFirstNonAAncestorFrame ( nsIFrame *  aStartFrame  )  [static]

Find the first frame, starting with aStartFrame and going up its parent chain, that is not an svgAFrame.

static float nsSVGUtils::GetFontSize ( mozilla::dom::Element aElement  )  [static]
static float nsSVGUtils::GetFontSize ( nsStyleContext aStyleContext  )  [static]
static float nsSVGUtils::GetFontSize ( nsIFrame *  aFrame  )  [static]
static float nsSVGUtils::GetFontXHeight ( mozilla::dom::Element aElement  )  [static]
static float nsSVGUtils::GetFontXHeight ( nsIFrame *  aFrame  )  [static]
static float nsSVGUtils::GetFontXHeight ( nsStyleContext aStyleContext  )  [static]
static nsSVGDisplayContainerFrame* nsSVGUtils::GetNearestSVGViewport ( nsIFrame *  aFrame  )  [static]

Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame.

aFrame must be an SVG frame. If aFrame is of type nsGkAtoms::svgOuterSVGFrame, returns nsnull.

static already_AddRefed<nsIDOMSVGElement> nsSVGUtils::GetNearestViewportElement ( nsIContent *  aContent  )  [static]
static nsSVGOuterSVGFrame* nsSVGUtils::GetOuterSVGFrame ( nsIFrame *  aFrame  )  [static]
static nsIFrame* nsSVGUtils::GetOuterSVGFrameAndCoveredRegion ( nsIFrame *  aFrame,
nsRect aRect 
) [static]

Get the covered region for a frame.

Return null if it's not an SVG frame.

Parameters:
aRect gets a rectangle in app units
Returns:
the outer SVG frame which aRect is relative to
static mozilla::dom::Element* nsSVGUtils::GetParentElement ( nsIContent *  aContent  )  [static]
static gfxRect nsSVGUtils::GetRelativeRect ( PRUint16  aUnits,
const nsSVGLength2 *  aXYWH,
const gfxRect aBBox,
nsIFrame *  aFrame 
) [static]

Compute a rectangle in userSpaceOnUse or objectBoundingBoxUnits.

Parameters:
aXYWH pointer to 4 consecutive nsSVGLength2 objects containing the x, y, width and height values in that order
aBBox the bounding box of the object the rect is relative to; may be null if aUnits is not SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
aFrame the object in which to interpret user-space units; may be null if aUnits is SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
static gfxMatrix nsSVGUtils::GetViewBoxTransform ( nsSVGElement *  aElement,
float  aViewportWidth,
float  aViewportHeight,
float  aViewboxX,
float  aViewboxY,
float  aViewboxWidth,
float  aViewboxHeight,
const SVGPreserveAspectRatio aPreserveAspectRatio 
) [static]
static gfxMatrix nsSVGUtils::GetViewBoxTransform ( nsSVGElement *  aElement,
float  aViewportWidth,
float  aViewportHeight,
float  aViewboxX,
float  aViewboxY,
float  aViewboxWidth,
float  aViewboxHeight,
const SVGAnimatedPreserveAspectRatio aPreserveAspectRatio 
) [static]
static nsIFrame* nsSVGUtils::HitTestChildren ( nsIFrame *  aFrame,
const nsPoint aPoint 
) [static]
static PRBool nsSVGUtils::HitTestClip ( nsIFrame *  aFrame,
const nsPoint aPoint 
) [static]
static PRBool nsSVGUtils::HitTestRect ( const gfxMatrix aMatrix,
float  aRX,
float  aRY,
float  aRWidth,
float  aRHeight,
float  aX,
float  aY 
) [static]
static void nsSVGUtils::InvalidateCoveredRegion ( nsIFrame *  aFrame  )  [static]

Invalidates the area covered by the frame.

static PRBool nsSVGUtils::IsInnerSVG ( nsIContent *  aContent  )  [static]

Returns true if aContent is an SVG <svg> element that is the child of another non-foreignObject SVG element.

static float nsSVGUtils::MaxExpansion ( const gfxMatrix aMatrix  )  [static]
static void nsSVGUtils::NotifyAncestorsOfFilterRegionChange ( nsIFrame *  aFrame  )  [static]
static void nsSVGUtils::NotifyChildrenOfSVGChange ( nsIFrame *  aFrame,
PRUint32  aFlags 
) [static]
static float nsSVGUtils::ObjectSpace ( const gfxRect aRect,
const nsSVGLength2 *  aLength 
) [static]
static void nsSVGUtils::PaintFrameWithEffects ( nsSVGRenderState aContext,
const nsIntRect aDirtyRect,
nsIFrame *  aFrame 
) [static]
static gfxRect nsSVGUtils::PathExtentsToMaxStrokeExtents ( const gfxRect aPathExtents,
nsSVGGeometryFrame *  aFrame 
) [static]

Compute the maximum possible device space stroke extents of a path given the path's device space path extents, its stroke style and its ctm.

This is a workaround for the lack of suitable cairo API for getting the tight device space stroke extents of a path. This basically gives us the tightest extents that we can guarantee fully enclose the inked stroke without doing the calculations for the actual tight extents. We exploit the fact that cairo does have an API for getting the tight device space fill/path extents.

This should die once bug 478152 is fixed.

static void nsSVGUtils::PremultiplyImageDataAlpha ( PRUint8 *  data,
PRInt32  stride,
const nsIntRect rect 
) [static]
static nsresult nsSVGUtils::ReportToConsole ( nsIDocument *  doc,
const char *  aWarning,
const PRUnichar **  aParams,
PRUint32  aParamsLength 
) [static]
static PRBool nsSVGUtils::RootSVGElementHasViewbox ( const nsIContent *  aRootSVGElem  )  [static]

Given a nsIContent* that is actually an nsSVGSVGElement*, this method checks whether it currently has a valid viewBox, and returns true if so.

No other type of element should be passed to this method. (In debug builds, anything non-<svg> will trigger an abort; in non-debug builds, it will trigger a PR_FALSE return-value as a safe fallback.)

static void nsSVGUtils::SetClipRect ( gfxContext aContext,
const gfxMatrix aCTM,
const gfxRect aRect 
) [static]
static nsRect nsSVGUtils::ToAppPixelRect ( nsPresContext aPresContext,
const gfxRect rect 
) [static]
static nsRect nsSVGUtils::ToAppPixelRect ( nsPresContext aPresContext,
double  xmin,
double  ymin,
double  xmax,
double  ymax 
) [static]
static void nsSVGUtils::UnPremultiplyImageDataAlpha ( PRUint8 *  data,
PRInt32  stride,
const nsIntRect rect 
) [static]
static void nsSVGUtils::UpdateGraphic ( nsISVGChildFrame *  aSVGFrame  )  [static]
static float nsSVGUtils::UserSpace ( nsSVGElement *  aSVGElement,
const nsSVGLength2 *  aLength 
) [static]
static float nsSVGUtils::UserSpace ( nsIFrame *  aFrame,
const nsSVGLength2 *  aLength 
) [static]

The documentation for this class was generated from the following file: