Bug 335870 - Remove nsISVGGeometrySource. r+sr=roc

This commit is contained in:
tor%cs.brown.edu 2006-05-02 15:05:25 +00:00
Родитель 1c1fe64948
Коммит b21b4b195e
37 изменённых файлов: 1099 добавлений и 1785 удалений

Просмотреть файл

@ -74,6 +74,7 @@ CPPSRCS = \
nsSVGFilterFrame.cpp \
nsSVGGFrame.cpp \
nsSVGGenericContainerFrame.cpp \
nsSVGGeometryFrame.cpp \
nsSVGGlyphFrame.cpp \
nsSVGGradientFrame.cpp \
nsSVGImageFrame.cpp \

Просмотреть файл

@ -37,7 +37,6 @@
#include "nsSVGFilterFrame.h"
#include "nsIDocument.h"
#include "nsISVGValueUtils.h"
#include "nsISVGGeometrySource.h"
#include "nsSVGMatrix.h"
#include "nsISVGRenderer.h"
#include "nsISVGRendererCanvas.h"
@ -285,18 +284,10 @@ nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
return NS_OK;
}
nsCOMPtr<nsIDOMSVGMatrix> ctm;
nsIFrame *frame;
CallQueryInterface(aTarget, &frame);
nsISVGContainerFrame *aContainer;
CallQueryInterface(aTarget, &aContainer);
if (aContainer)
ctm = aContainer->GetCanvasTM();
else {
nsISVGGeometrySource *aSource;
CallQueryInterface(aTarget, &aSource);
if (aSource)
aSource->GetCanvasTM(getter_AddRefs(ctm));
}
nsCOMPtr<nsIDOMSVGMatrix> ctm = nsSVGUtils::GetCanvasTM(frame);
float s1, s2;
ctm->GetA(&s1);
@ -305,8 +296,6 @@ nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
fprintf(stderr, "scales: %f %f\n", s1, s2);
#endif
nsIFrame *frame;
CallQueryInterface(aTarget, &frame);
nsSVGElement *target = NS_STATIC_CAST(nsSVGElement*, frame->GetContent());
aTarget->SetMatrixPropagation(PR_FALSE);
@ -469,18 +458,7 @@ nsSVGFilterFrame::GetInvalidationRegion(nsIFrame *aTarget,
NS_STATIC_CAST(nsSVGElement*, aTarget->GetContent());
nsISVGChildFrame *svg;
nsCOMPtr<nsIDOMSVGMatrix> ctm;
nsISVGContainerFrame *aContainer;
CallQueryInterface(aTarget, &aContainer);
if (aContainer)
ctm = aContainer->GetCanvasTM();
else {
nsISVGGeometrySource *source;
CallQueryInterface(aTarget, &source);
if (source)
source->GetCanvasTM(getter_AddRefs(ctm));
}
nsCOMPtr<nsIDOMSVGMatrix> ctm = nsSVGUtils::GetCanvasTM(aTarget);
CallQueryInterface(aTarget, &svg);

Просмотреть файл

@ -0,0 +1,429 @@
/* -*- 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 IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#include "nsPresContext.h"
#include "nsSVGGradient.h"
#include "nsSVGPattern.h"
#include "nsISVGValueUtils.h"
#include "nsSVGUtils.h"
#include "nsSVGGeometryFrame.h"
#include "nsISVGGradient.h"
#include "nsISVGPattern.h"
//----------------------------------------------------------------------
// nsISupports methods
NS_INTERFACE_MAP_BEGIN(nsSVGGeometryFrame)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_END_INHERITING(nsSVGGeometryFrameBase)
//----------------------------------------------------------------------
nsSVGGeometryFrame::nsSVGGeometryFrame(nsStyleContext* aContext)
: nsSVGGeometryFrameBase(aContext),
mFillGradient(nsnull), mStrokeGradient(nsnull),
mFillPattern(nsnull), mStrokePattern(nsnull)
{
}
nsSVGGeometryFrame::~nsSVGGeometryFrame()
{
if (mFillGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillGradient);
}
if (mStrokeGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokeGradient);
}
if (mFillPattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillPattern);
}
if (mStrokePattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokePattern);
}
}
NS_IMETHODIMP
nsSVGGeometryFrame::DidSetStyleContext()
{
// One of the styles that might have been changed are the urls that
// point to gradients, etc. Drop our cached values to those
if (mFillGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillGradient);
mFillGradient = nsnull;
}
if (mStrokeGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokeGradient);
mStrokeGradient = nsnull;
}
if (mFillPattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillPattern);
mFillPattern = nsnull;
}
if (mStrokePattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokePattern);
mStrokePattern = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsSVGGeometryFrame::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
return NS_OK;
}
NS_IMETHODIMP
nsSVGGeometryFrame::DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
nsISVGGradient *gradient;
CallQueryInterface(observable, &gradient);
if (gradient) {
// Yes, we need to handle this differently
if (mFillGradient == gradient) {
if (aModType == nsISVGValue::mod_die) {
mFillGradient = nsnull;
}
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_FILL_PAINT);
} else {
// No real harm in assuming a stroke gradient at this point
if (aModType == nsISVGValue::mod_die) {
mStrokeGradient = nsnull;
}
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_STROKE_PAINT);
}
return NS_OK;
}
nsISVGPattern *pval;
CallQueryInterface(observable, &pval);
if (pval) {
// Handle Patterns
if (mFillPattern == pval) {
if (aModType == nsISVGValue::mod_die) {
mFillPattern = nsnull;
}
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_FILL_PAINT);
} else {
// Assume stroke pattern
if (aModType == nsISVGValue::mod_die) {
mStrokePattern = nsnull;
}
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_STROKE_PAINT);
}
return NS_OK;
}
return NS_OK;
}
//----------------------------------------------------------------------
float
nsSVGGeometryFrame::GetStrokeOpacity()
{
return GetStyleSVG()->mStrokeOpacity;
}
float
nsSVGGeometryFrame::GetStrokeWidth()
{
return nsSVGUtils::CoordToFloat(GetPresContext(),
mContent, GetStyleSVG()->mStrokeWidth);
}
nsresult
nsSVGGeometryFrame::GetStrokeDashArray(double **aDashes, PRUint32 *aCount)
{
*aDashes = nsnull;
*aCount = 0;
PRUint32 count = GetStyleSVG()->mStrokeDasharrayLength;
double *dashes = nsnull;
if (count) {
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
nsPresContext *presContext = GetPresContext();
float totalLength = 0.0f;
dashes = new double[count];
if (dashes) {
for (PRUint32 i = 0; i < count; i++) {
dashes[i] =
nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
if (dashes[i] < 0.0f) {
delete [] dashes;
return NS_OK;
}
totalLength += dashes[i];
}
} else {
return NS_ERROR_OUT_OF_MEMORY;
}
if (totalLength == 0.0f) {
delete [] dashes;
return NS_OK;
}
*aDashes = dashes;
*aCount = count;
}
return NS_OK;
}
float
nsSVGGeometryFrame::GetStrokeDashoffset()
{
return
nsSVGUtils::CoordToFloat(GetPresContext(), mContent,
GetStyleSVG()->mStrokeDashoffset);
}
float
nsSVGGeometryFrame::GetFillOpacity()
{
return GetStyleSVG()->mFillOpacity;
}
PRUint16
nsSVGGeometryFrame::GetClipRule()
{
return GetStyleSVG()->mClipRule;
}
PRUint16
nsSVGGeometryFrame::GetStrokePaintType()
{
float strokeWidth = GetStrokeWidth();
// cairo will stop rendering if stroke-width is less than or equal to zero
return strokeWidth <= 0 ? eStyleSVGPaintType_None
: GetStyleSVG()->mStroke.mType;
}
nsresult
nsSVGGeometryFrame::GetStrokePaintServerType(PRUint16 *aStrokePaintServerType) {
return nsSVGUtils::GetPaintType(aStrokePaintServerType,
GetStyleSVG()->mStroke, mContent,
GetPresContext()->PresShell());
}
nsresult
nsSVGGeometryFrame::GetStrokeGradient(nsISVGGradient **aGrad)
{
nsresult rv = NS_OK;
*aGrad = nsnull;
if (!mStrokeGradient) {
nsIURI *aServer;
aServer = GetStyleSVG()->mStroke.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGGradient(&mStrokeGradient, aServer, mContent,
GetPresContext()->PresShell());
NS_ADD_SVGVALUE_OBSERVER(mStrokeGradient);
}
*aGrad = mStrokeGradient;
return rv;
}
nsresult
nsSVGGeometryFrame::GetStrokePattern(nsISVGPattern **aPat)
{
nsresult rv = NS_OK;
*aPat = nsnull;
if (!mStrokePattern) {
nsIURI *aServer;
aServer = GetStyleSVG()->mStroke.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGPattern(&mStrokePattern, aServer, mContent,
GetPresContext()->PresShell());
if (mStrokePattern)
NS_ADD_SVGVALUE_OBSERVER(mStrokePattern);
}
*aPat = mStrokePattern;
return rv;
}
PRUint16
nsSVGGeometryFrame::GetFillPaintType()
{
return GetStyleSVG()->mFill.mType;
}
nsresult
nsSVGGeometryFrame::GetFillPaintServerType(PRUint16 *aFillPaintServerType)
{
return nsSVGUtils::GetPaintType(aFillPaintServerType,
GetStyleSVG()->mFill, mContent,
GetPresContext()->PresShell());
}
nsresult
nsSVGGeometryFrame::GetFillGradient(nsISVGGradient **aGrad)
{
nsresult rv = NS_OK;
*aGrad = nsnull;
if (!mFillGradient) {
nsIURI *aServer;
aServer = GetStyleSVG()->mFill.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGGradient(&mFillGradient, aServer, mContent,
GetPresContext()->PresShell());
NS_ADD_SVGVALUE_OBSERVER(mFillGradient);
}
*aGrad = mFillGradient;
return rv;
}
nsresult
nsSVGGeometryFrame::GetFillPattern(nsISVGPattern **aPat)
{
nsresult rv = NS_OK;
*aPat = nsnull;
if (!mFillPattern) {
nsIURI *aServer;
aServer = GetStyleSVG()->mFill.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the pattern
rv = NS_GetSVGPattern(&mFillPattern, aServer, mContent,
GetPresContext()->PresShell());
if (mFillPattern)
NS_ADD_SVGVALUE_OBSERVER(mFillPattern);
}
*aPat = mFillPattern;
return rv;
}
PRBool
nsSVGGeometryFrame::IsClipChild()
{
nsCOMPtr<nsIContent> node(mContent);
do {
if (node->Tag() == nsGkAtoms::clipPath) {
return PR_TRUE;
break;
}
node = node->GetParent();
} while (node);
return PR_FALSE;
}
static void
SetupCairoColor(cairo_t *aCtx, nscolor aRGB, float aOpacity)
{
cairo_set_source_rgba(aCtx,
NS_GET_R(aRGB)/255.0,
NS_GET_G(aRGB)/255.0,
NS_GET_B(aRGB)/255.0,
aOpacity);
}
void
nsSVGGeometryFrame::SetupCairoFill(cairo_t *aCtx)
{
if (GetStyleSVG()->mFillRule == NS_STYLE_FILL_RULE_EVENODD)
cairo_set_fill_rule(aCtx, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(aCtx, CAIRO_FILL_RULE_WINDING);
SetupCairoColor(aCtx, GetStyleSVG()->mFill.mPaint.mColor, GetFillOpacity());
}
void
nsSVGGeometryFrame::SetupCairoStrokeGeometry(cairo_t *aCtx)
{
cairo_set_line_width(aCtx, GetStrokeWidth());
switch (GetStyleSVG()->mStrokeLinecap) {
case NS_STYLE_STROKE_LINECAP_BUTT:
cairo_set_line_cap(aCtx, CAIRO_LINE_CAP_BUTT);
break;
case NS_STYLE_STROKE_LINECAP_ROUND:
cairo_set_line_cap(aCtx, CAIRO_LINE_CAP_ROUND);
break;
case NS_STYLE_STROKE_LINECAP_SQUARE:
cairo_set_line_cap(aCtx, CAIRO_LINE_CAP_SQUARE);
break;
}
cairo_set_miter_limit(aCtx, GetStyleSVG()->mStrokeMiterlimit);
switch (GetStyleSVG()->mStrokeLinejoin) {
case NS_STYLE_STROKE_LINEJOIN_MITER:
cairo_set_line_join(aCtx, CAIRO_LINE_JOIN_MITER);
break;
case NS_STYLE_STROKE_LINEJOIN_ROUND:
cairo_set_line_join(aCtx, CAIRO_LINE_JOIN_ROUND);
break;
case NS_STYLE_STROKE_LINEJOIN_BEVEL:
cairo_set_line_join(aCtx, CAIRO_LINE_JOIN_BEVEL);
break;
}
}
void
nsSVGGeometryFrame::SetupCairoStroke(cairo_t *aCtx)
{
SetupCairoStrokeGeometry(aCtx);
double *dashArray;
PRUint32 count;
GetStrokeDashArray(&dashArray, &count);
if (count > 0) {
cairo_set_dash(aCtx, dashArray, count, GetStrokeDashoffset());
delete [] dashArray;
}
SetupCairoColor(aCtx,
GetStyleSVG()->mStroke.mPaint.mColor, GetStrokeOpacity());
}

Просмотреть файл

@ -0,0 +1,141 @@
/* -*- 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 IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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_SVGGEOMETRYFRAME_H__
#define __NS_SVGGEOMETRYFRAME_H__
#include "nsFrame.h"
#include "nsWeakReference.h"
#include "nsISVGValueObserver.h"
#include <cairo.h>
class nsISVGGradient;
class nsISVGPattern;
typedef nsFrame nsSVGGeometryFrameBase;
/* nsSVGGeometryFrame is a base class for SVG objects that directly
* have geometry (circle, ellipse, line, polyline, polygon, path, and
* glyph frames). It knows how to convert the style information into
* cairo context information and stores the fill/stroke paint
* servers. */
class nsSVGGeometryFrame : public nsSVGGeometryFrameBase,
public nsISVGValueObserver,
public nsSupportsWeakReference
{
public:
nsSVGGeometryFrame(nsStyleContext *aContext);
~nsSVGGeometryFrame();
// nsIFrame interface:
NS_IMETHOD DidSetStyleContext();
// nsISupports interface:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
// nsISVGValueObserver interface:
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
// nsSVGGeometryFrame methods:
NS_IMETHOD GetCanvasTM(nsIDOMSVGMatrix * *aCanvasTM) = 0;
PRUint16 GetClipRule();
PRBool IsClipChild();
float GetStrokeWidth();
float GetStrokeOpacity();
float GetFillOpacity();
PRUint16 GetStrokePaintType();
nsresult GetStrokePaintServerType(PRUint16 *aStrokePaintServerType);
nsresult GetStrokeGradient(nsISVGGradient **aGrad);
nsresult GetStrokePattern(nsISVGPattern **aPat);
PRUint16 GetFillPaintType();
nsresult GetFillPaintServerType(PRUint16 *aFillPaintServerType);
nsresult GetFillGradient(nsISVGGradient **aGrad);
nsresult GetFillPattern(nsISVGPattern **aPat);
// Set up a cairo context for filling a path
void SetupCairoFill(cairo_t *aCtx);
// Set up a cairo context for measuring a stroked path
void SetupCairoStrokeGeometry(cairo_t *aCtx);
// Set up a cairo context for stroking path
void SetupCairoStroke(cairo_t *aCtx);
enum {
UPDATEMASK_NOTHING = 0x00000000,
UPDATEMASK_CANVAS_TM = 0x00000001,
UPDATEMASK_STROKE_OPACITY = 0x00000002,
UPDATEMASK_STROKE_WIDTH = 0x00000004,
UPDATEMASK_STROKE_DASH_ARRAY = 0x00000008,
UPDATEMASK_STROKE_DASHOFFSET = 0x00000010,
UPDATEMASK_STROKE_LINECAP = 0x00000020,
UPDATEMASK_STROKE_LINEJOIN = 0x00000040,
UPDATEMASK_STROKE_MITERLIMIT = 0x00000080,
UPDATEMASK_FILL_OPACITY = 0x00000100,
UPDATEMASK_FILL_RULE = 0x00000200,
UPDATEMASK_STROKE_PAINT_TYPE = 0x00000400,
UPDATEMASK_STROKE_PAINT = 0x00000800,
UPDATEMASK_FILL_PAINT_TYPE = 0x00001000,
UPDATEMASK_FILL_PAINT = 0x00002000,
UPDATEMASK_ALL = 0xFFFFFFFF
};
enum {
PAINT_TYPE_GRADIENT = 0,
PAINT_TYPE_PATTERN = 1
};
protected:
virtual nsresult UpdateGraphic(PRUint32 flags,
PRBool suppressInvalidation = PR_FALSE) = 0;
private:
nsresult GetStrokeDashArray(double **arr, PRUint32 *count);
float GetStrokeDashoffset();
nsISVGGradient* mFillGradient;
nsISVGGradient* mStrokeGradient;
nsISVGPattern* mFillPattern;
nsISVGPattern* mStrokePattern;
};
#endif // __NS_SVGGEOMETRYFRAME_H__

Просмотреть файл

@ -36,14 +36,10 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsFrame.h"
#include "nsISVGRendererGlyphGeometry.h"
#include "nsISVGRendererGlyphMetrics.h"
#include "nsISVGRenderer.h"
#include "nsISVGGlyphGeometrySource.h"
#include "nsISVGGlyphFragmentLeaf.h"
#include "nsITextContent.h"
#include "nsISVGChildFrame.h"
#include "nsISVGOuterSVGFrame.h"
#include "nsISVGTextFrame.h"
#include "nsISVGRendererRegion.h"
@ -67,137 +63,7 @@
#include "nsLayoutAtoms.h"
#include "nsSVGUtils.h"
#include "nsISVGPathFlatten.h"
typedef nsFrame nsSVGGlyphFrameBase;
class nsSVGGlyphFrame : public nsSVGGlyphFrameBase,
public nsISVGValueObserver,
public nsSupportsWeakReference,
public nsISVGGlyphGeometrySource, // : nsISVGGlyphMetricsSource : nsISVGGeometrySource
public nsISVGGlyphFragmentLeaf, // : nsISVGGlyphFragmentNode
public nsISVGChildFrame
{
protected:
friend nsIFrame*
NS_NewSVGGlyphFrame(nsIPresShell* aPresShell, nsIContent* aContent,
nsIFrame* parentFrame, nsStyleContext* aContext);
nsSVGGlyphFrame(nsStyleContext* aContext);
virtual ~nsSVGGlyphFrame();
public:
// nsISupports interface:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
// nsIFrame interface:
NS_IMETHOD
Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
NS_IMETHOD CharacterDataChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRBool aAppend);
NS_IMETHOD DidSetStyleContext();
NS_IMETHOD SetSelected(nsPresContext* aPresContext,
nsIDOMRange* aRange,
PRBool aSelected,
nsSpread aSpread);
NS_IMETHOD GetSelected(PRBool *aSelected) const;
NS_IMETHOD IsSelectable(PRBool* aIsSelectable, PRUint8* aSelectStyle) const;
/**
* Get the "type" of the frame
*
* @see nsLayoutAtoms::svgGlyphFrame
*/
virtual nsIAtom* GetType() const;
virtual PRBool IsFrameOfType(PRUint32 aFlags) const;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const
{
return MakeFrameName(NS_LITERAL_STRING("SVGGlyph"), aResult);
}
#endif
// nsISVGValueObserver
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType);
NS_IMETHOD DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType);
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
NS_IMETHOD_(already_AddRefed<nsISVGRendererRegion>) GetCoveredRegion();
NS_IMETHOD InitialUpdate();
NS_IMETHOD NotifyCanvasTMChanged(PRBool suppressInvalidation);
NS_IMETHOD NotifyRedrawSuspended();
NS_IMETHOD NotifyRedrawUnsuspended();
NS_IMETHOD SetMatrixPropagation(PRBool aPropagate) { return NS_OK; }
NS_IMETHOD SetOverrideCTM(nsIDOMSVGMatrix *aCTM) { return NS_ERROR_FAILURE; }
NS_IMETHOD GetBBox(nsIDOMSVGRect **_retval);
// nsISVGGeometrySource interface:
NS_DECL_NSISVGGEOMETRYSOURCE
// nsISVGGlyphMetricsSource interface:
NS_DECL_NSISVGGLYPHMETRICSSOURCE
// nsISVGGlyphGeometrySource interface:
NS_DECL_NSISVGGLYPHGEOMETRYSOURCE
// nsISVGGlyphFragmentLeaf interface:
NS_IMETHOD_(void) SetGlyphPosition(float x, float y);
NS_IMETHOD_(float) GetGlyphPositionX();
NS_IMETHOD_(float) GetGlyphPositionY();
NS_IMETHOD GetGlyphMetrics(nsISVGRendererGlyphMetrics** metrics);
NS_IMETHOD_(PRBool) IsStartOfChunk(); // == is new absolutely positioned chunk.
NS_IMETHOD_(void) GetAdjustedPosition(/* inout */ float &x, /* inout */ float &y);
NS_IMETHOD_(PRUint32) GetNumberOfChars();
NS_IMETHOD_(PRUint32) GetCharNumberOffset();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetX();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetY();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDx();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDy();
NS_IMETHOD_(PRUint16) GetTextAnchor();
NS_IMETHOD_(PRBool) IsAbsolutelyPositioned();
// nsISVGGlyphFragmentNode interface:
NS_IMETHOD_(nsISVGGlyphFragmentLeaf *) GetFirstGlyphFragment();
NS_IMETHOD_(nsISVGGlyphFragmentLeaf *) GetNextGlyphFragment();
NS_IMETHOD_(PRUint32) BuildGlyphFragmentTree(PRUint32 charNum, PRBool lastBranch);
NS_IMETHOD_(void) NotifyMetricsSuspended();
NS_IMETHOD_(void) NotifyMetricsUnsuspended();
NS_IMETHOD_(void) NotifyGlyphFragmentTreeSuspended();
NS_IMETHOD_(void) NotifyGlyphFragmentTreeUnsuspended();
protected:
void UpdateGeometry(PRUint32 flags, PRBool bRedraw,
PRBool suppressInvalidation);
void UpdateMetrics(PRUint32 flags);
void UpdateFragmentTree();
nsISVGTextFrame *GetTextFrame();
NS_IMETHOD Update(PRUint32 aFlags);
nsCOMPtr<nsISVGRendererGlyphGeometry> mGeometry;
nsCOMPtr<nsISVGRendererGlyphMetrics> mMetrics;
float mX, mY;
PRUint32 mGeometryUpdateFlags;
PRUint32 mMetricsUpdateFlags;
PRUint32 mCharOffset;
nsString mCharacterData;
nsISVGGradient* mFillGradient;
nsISVGGradient* mStrokeGradient;
nsISVGPattern* mFillPattern;
nsISVGPattern* mStrokePattern;
PRPackedBool mFragmentTreeDirty;
};
#include "nsSVGGlyphFrame.h"
//----------------------------------------------------------------------
// Implementation
@ -222,40 +88,18 @@ nsSVGGlyphFrame::nsSVGGlyphFrame(nsStyleContext* aContext)
: nsSVGGlyphFrameBase(aContext),
mGeometryUpdateFlags(0), mMetricsUpdateFlags(0),
mCharOffset(0),
mFillGradient(nsnull), mStrokeGradient(nsnull),
mFillPattern(nsnull), mStrokePattern(nsnull),
mFragmentTreeDirty(PR_FALSE)
{
}
nsSVGGlyphFrame::~nsSVGGlyphFrame()
{
if (mFillGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillGradient);
}
if (mStrokeGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokeGradient);
}
if (mFillPattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillPattern);
}
if (mStrokePattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokePattern);
}
}
//----------------------------------------------------------------------
// nsISupports methods
NS_INTERFACE_MAP_BEGIN(nsSVGGlyphFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGGeometrySource)
NS_INTERFACE_MAP_ENTRY(nsISVGGlyphMetricsSource)
NS_INTERFACE_MAP_ENTRY(nsISVGGlyphGeometrySource)
NS_INTERFACE_MAP_ENTRY(nsISVGGlyphFragmentLeaf)
NS_INTERFACE_MAP_ENTRY(nsISVGGlyphFragmentNode)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame)
NS_INTERFACE_MAP_END_INHERITING(nsSVGGlyphFrameBase)
@ -288,7 +132,7 @@ nsSVGGlyphFrame::Init(nsIContent* aContent,
outerSVGFrame->GetRenderer(getter_AddRefs(renderer));
if (renderer) {
renderer->CreateGlyphMetrics(this, getter_AddRefs(mMetrics));
renderer->CreateGlyphGeometry(this, getter_AddRefs(mGeometry));
renderer->CreateGlyphGeometry(getter_AddRefs(mGeometry));
}
DidSetStyleContext();
@ -304,11 +148,11 @@ nsSVGGlyphFrame::CharacterDataChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRBool aAppend)
{
return Update(nsISVGGeometrySource::UPDATEMASK_ALL);
return UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_ALL);
}
NS_IMETHODIMP
nsSVGGlyphFrame::Update(PRUint32 aFlags)
nsresult
nsSVGGlyphFrame::UpdateGraphic(PRUint32 aFlags, PRBool suppressInvalidation)
{
#ifdef DEBUG
// printf("** nsSVGGlyphFrame::Update\n");
@ -331,24 +175,7 @@ nsSVGGlyphFrame::Update(PRUint32 aFlags)
NS_IMETHODIMP
nsSVGGlyphFrame::DidSetStyleContext()
{
// One of the styles that might have been changed are the urls that
// point to gradients, etc. Drop our cached values to those
if (mFillGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillGradient);
mFillGradient = nsnull;
}
if (mStrokeGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokeGradient);
mStrokeGradient = nsnull;
}
if (mFillPattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillPattern);
mFillPattern = nsnull;
}
if (mStrokePattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokePattern);
mStrokePattern = nsnull;
}
nsSVGGlyphFrameBase::DidSetStyleContext();
return CharacterDataChanged(nsnull, nsnull, PR_FALSE);
}
@ -416,64 +243,6 @@ nsSVGGlyphFrame::IsFrameOfType(PRUint32 aFlags) const
return !(aFlags & ~nsIFrame::eSVG);
}
//----------------------------------------------------------------------
// nsISVGValueObserver methods:
NS_IMETHODIMP
nsSVGGlyphFrame::WillModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
return NS_OK;
}
NS_IMETHODIMP
nsSVGGlyphFrame::DidModifySVGObservable (nsISVGValue* observable,
nsISVGValue::modificationType aModType)
{
// Is this a gradient?
nsISVGGradient *val;
CallQueryInterface(observable, &val);
if (val) {
// Yes, we need to handle this differently
if (mFillGradient == val) {
if (aModType == nsISVGValue::mod_die) {
mFillGradient = nsnull;
}
return Update(nsISVGGeometrySource::UPDATEMASK_FILL_PAINT);
} else {
// No real harm in assuming a stroke gradient at this point
if (aModType == nsISVGValue::mod_die) {
mStrokeGradient = nsnull;
}
return Update(nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT);
}
} else {
nsISVGPattern *pval;
CallQueryInterface(observable, &pval);
if (pval) {
// Handle Patterns
if (mFillPattern == pval) {
if (aModType == nsISVGValue::mod_die) {
mFillPattern = nsnull;
}
return Update(nsISVGGeometrySource::UPDATEMASK_FILL_PAINT);
} else {
// Assume stroke pattern
if (aModType == nsISVGValue::mod_die) {
mStrokePattern = nsnull;
}
return Update(nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT);
}
} else {
// No, all of our other observables update the canvastm by default
return Update(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM);
}
}
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGChildFrame methods
@ -486,7 +255,7 @@ nsSVGGlyphFrame::PaintSVG(nsISVGRendererCanvas* canvas)
if (!GetStyleVisibility()->IsVisible())
return NS_OK;
mGeometry->Render(canvas);
mGeometry->Render(this, canvas);
return NS_OK;
}
@ -534,7 +303,7 @@ nsSVGGlyphFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
return NS_OK;
PRBool isHit;
mGeometry->ContainsPoint(x, y, &isHit);
mGeometry->ContainsPoint(this, x, y, &isHit);
if (isHit)
*hit = this;
@ -546,20 +315,20 @@ nsSVGGlyphFrame::GetCoveredRegion()
{
nsISVGRendererRegion *region = nsnull;
if (mGeometry)
mGeometry->GetCoveredRegion(&region);
mGeometry->GetCoveredRegion(this, &region);
return region;
}
NS_IMETHODIMP
nsSVGGlyphFrame::InitialUpdate()
{
return Update(nsISVGGeometrySource::UPDATEMASK_ALL);
return UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_ALL);
}
NS_IMETHODIMP
nsSVGGlyphFrame::NotifyCanvasTMChanged(PRBool suppressInvalidation)
{
UpdateGeometry(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM,
UpdateGeometry(nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM,
PR_TRUE, suppressInvalidation);
return NS_OK;
@ -580,7 +349,7 @@ nsSVGGlyphFrame::NotifyRedrawUnsuspended()
if (mGeometryUpdateFlags != 0) {
nsCOMPtr<nsISVGRendererRegion> dirty_region;
mGeometry->Update(mGeometryUpdateFlags, getter_AddRefs(dirty_region));
mGeometry->Update(this, mGeometryUpdateFlags, getter_AddRefs(dirty_region));
if (dirty_region) {
nsISVGOuterSVGFrame* outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(this);
if (outerSVGFrame)
@ -597,22 +366,12 @@ nsSVGGlyphFrame::GetBBox(nsIDOMSVGRect **_retval)
*_retval = nsnull;
if (mGeometry)
return mGeometry->GetBoundingBox(_retval);
return mGeometry->GetBoundingBox(this, _retval);
return NS_ERROR_FAILURE;
}
//----------------------------------------------------------------------
// nsISVGGeometrySource methods:
/* [noscript] readonly attribute nsPresContext presContext; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetPresContext(nsPresContext * *aPresContext)
{
// XXX gcc 3.2.2 requires the explicit 'nsSVGGlyphFrameBase::' qualification
*aPresContext = nsSVGGlyphFrameBase::GetPresContext();
NS_ADDREF(*aPresContext);
return NS_OK;
}
// nsSVGGeometryFrame methods:
/* readonly attribute nsIDOMSVGMatrix canvasTM; */
NS_IMETHODIMP
@ -632,277 +391,6 @@ nsSVGGlyphFrame::GetCanvasTM(nsIDOMSVGMatrix * *aCTM)
return NS_OK;
}
/* readonly attribute float strokeOpacity; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeOpacity(float *aStrokeOpacity)
{
*aStrokeOpacity =
GetStyleSVG()->mStrokeOpacity * GetStyleDisplay()->mOpacity;
return NS_OK;
}
/* readonly attribute float strokeWidth; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeWidth(float *aStrokeWidth)
{
*aStrokeWidth =
nsSVGUtils::CoordToFloat(nsSVGGlyphFrameBase::GetPresContext(),
mContent, GetStyleSVG()->mStrokeWidth);
return NS_OK;
}
/* void getStrokeDashArray ([array, size_is (count)] out float arr, out unsigned long count); */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
{
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
nsPresContext *presContext = nsSVGGlyphFrameBase::GetPresContext();
float totalLength = 0.0f;
*count = GetStyleSVG()->mStrokeDasharrayLength;
*arr = nsnull;
if (*count) {
*arr = (float *) nsMemory::Alloc(*count * sizeof(float));
if (*arr) {
for (PRUint32 i = 0; i < *count; i++) {
(*arr)[i] = nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
if ((*arr)[i] < 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
return NS_OK;
}
totalLength += (*arr)[i];
}
} else {
*count = 0;
return NS_ERROR_OUT_OF_MEMORY;
}
if (totalLength == 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
}
}
return NS_OK;
}
/* readonly attribute float strokeDashoffset; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeDashoffset(float *aStrokeDashoffset)
{
*aStrokeDashoffset =
nsSVGUtils::CoordToFloat(nsSVGGlyphFrameBase::GetPresContext(),
mContent, GetStyleSVG()->mStrokeDashoffset);
return NS_OK;
}
/* readonly attribute unsigned short strokeLinecap; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeLinecap(PRUint16 *aStrokeLinecap)
{
*aStrokeLinecap = GetStyleSVG()->mStrokeLinecap;
return NS_OK;
}
/* readonly attribute unsigned short strokeLinejoin; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeLinejoin(PRUint16 *aStrokeLinejoin)
{
*aStrokeLinejoin = GetStyleSVG()->mStrokeLinejoin;
return NS_OK;
}
/* readonly attribute float strokeMiterlimit; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeMiterlimit(float *aStrokeMiterlimit)
{
*aStrokeMiterlimit = GetStyleSVG()->mStrokeMiterlimit;
return NS_OK;
}
/* readonly attribute float fillOpacity; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetFillOpacity(float *aFillOpacity)
{
*aFillOpacity =
GetStyleSVG()->mFillOpacity * GetStyleDisplay()->mOpacity;
return NS_OK;
}
/* readonly attribute unsigned short fillRule; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetFillRule(PRUint16 *aFillRule)
{
*aFillRule = GetStyleSVG()->mFillRule;
return NS_OK;
}
/* readonly attribute unsigned short clipRule; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetClipRule(PRUint16 *aClipRule)
{
*aClipRule = GetStyleSVG()->mClipRule;
return NS_OK;
}
/* readonly attribute unsigned short strokePaintType; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokePaintType(PRUint16 *aStrokePaintType)
{
float strokeWidth;
GetStrokeWidth(&strokeWidth);
// cairo will stop rendering if stroke-width is less than or equal to zero
*aStrokePaintType = strokeWidth <= 0 ?
nsISVGGeometrySource::PAINT_TYPE_NONE :
GetStyleSVG()->mStroke.mType;
return NS_OK;
}
/* readonly attribute unsigned short strokePaintServerType; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokePaintServerType(PRUint16 *aStrokePaintServerType)
{
return nsSVGUtils::GetPaintType(aStrokePaintServerType, GetStyleSVG()->mStroke, mContent,
nsSVGGlyphFrameBase::GetPresContext()->PresShell());
}
/* [noscript] readonly attribute nscolor strokePaint; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokePaint(nscolor *aStrokePaint)
{
*aStrokePaint = GetStyleSVG()->mStroke.mPaint.mColor;
return NS_OK;
}
/* [noscript] void GetStrokeGradient(nsISVGGradient **aGrad); */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokeGradient(nsISVGGradient **aGrad)
{
nsresult rv = NS_OK;
*aGrad = nsnull;
if (!mStrokeGradient) {
nsIURI *aServer;
aServer = GetStyleSVG()->mStroke.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGGradient(&mStrokeGradient, aServer, mContent,
nsSVGGlyphFrameBase::GetPresContext()->PresShell());
NS_ADD_SVGVALUE_OBSERVER(mStrokeGradient);
}
*aGrad = mStrokeGradient;
return rv;
}
/* [noscript] void GetStrokePattern(nsISVGPattern **aPat); */
NS_IMETHODIMP
nsSVGGlyphFrame::GetStrokePattern(nsISVGPattern **aPat)
{
nsresult rv = NS_OK;
*aPat = nsnull;
if (!mStrokePattern) {
nsIURI *aServer;
aServer = GetStyleSVG()->mStroke.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGPattern(&mStrokePattern, aServer, mContent,
nsSVGGlyphFrameBase::GetPresContext()->PresShell());
if (mStrokePattern)
NS_ADD_SVGVALUE_OBSERVER(mStrokePattern);
}
*aPat = mStrokePattern;
return rv;
}
/* readonly attribute unsigned short fillPaintType; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetFillPaintType(PRUint16 *aFillPaintType)
{
*aFillPaintType = GetStyleSVG()->mFill.mType;
return NS_OK;
}
/* readonly attribute unsigned short fillPaintServerType; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetFillPaintServerType(PRUint16 *aFillPaintServerType)
{
return nsSVGUtils::GetPaintType(aFillPaintServerType, GetStyleSVG()->mFill, mContent,
nsSVGGlyphFrameBase::GetPresContext()->PresShell());
}
/* [noscript] readonly attribute nscolor fillPaint; */
NS_IMETHODIMP
nsSVGGlyphFrame::GetFillPaint(nscolor *aFillPaint)
{
*aFillPaint = GetStyleSVG()->mFill.mPaint.mColor;
return NS_OK;
}
/* [noscript] void GetFillGradient(nsISVGGradient **aGrad); */
NS_IMETHODIMP
nsSVGGlyphFrame::GetFillGradient(nsISVGGradient **aGrad)
{
nsresult rv = NS_OK;
*aGrad = nsnull;
if (!mFillGradient) {
nsIURI *aServer;
aServer = GetStyleSVG()->mFill.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGGradient(&mFillGradient, aServer, mContent,
nsSVGGlyphFrameBase::GetPresContext()->PresShell());
NS_ADD_SVGVALUE_OBSERVER(mFillGradient);
}
*aGrad = mFillGradient;
return rv;
}
/* [noscript] void GetFillPattern(nsISVGPattern **aPat); */
NS_IMETHODIMP
nsSVGGlyphFrame::GetFillPattern(nsISVGPattern **aPat)
{
nsresult rv = NS_OK;
*aPat = nsnull;
if (!mFillPattern) {
nsIURI *aServer;
aServer = GetStyleSVG()->mFill.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGPattern(&mFillPattern, aServer, mContent,
nsSVGGlyphFrameBase::GetPresContext()->PresShell());
if (mFillPattern)
NS_ADD_SVGVALUE_OBSERVER(mFillPattern);
}
*aPat = mFillPattern;
return rv;
}
/* [noscript] boolean isClipChild; */
NS_IMETHODIMP
nsSVGGlyphFrame::IsClipChild(PRBool *_retval)
{
*_retval = PR_FALSE;
nsCOMPtr<nsIContent> node(mContent);
do {
if (node->Tag() == nsSVGAtoms::clipPath) {
*_retval = PR_TRUE;
break;
}
node = node->GetParent();
} while (node);
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGGlyphMetricsSource methods:
@ -1146,8 +634,7 @@ nsSVGGlyphFrame::GetHighlight(PRUint32 *charnum, PRUint32 *nchars, nscolor *fore
return NS_ERROR_FAILURE;
}
// XXX gcc 3.2.2 requires the explicit 'nsSVGGlyphFrameBase::' qualification
nsPresContext *presContext = nsSVGGlyphFrameBase::GetPresContext();
nsPresContext *presContext = GetPresContext();
nsCOMPtr<nsITextContent> tc = do_QueryInterface(mContent);
NS_ASSERTION(tc, "no textcontent interface");
@ -1488,7 +975,7 @@ void nsSVGGlyphFrame::UpdateGeometry(PRUint32 flags, PRBool bRedraw,
NS_ASSERTION(!mFragmentTreeDirty, "dirty fragmenttree in nsSVGGlyphFrame::UpdateGeometry");
nsCOMPtr<nsISVGRendererRegion> dirty_region;
if (mGeometry)
mGeometry->Update(mGeometryUpdateFlags, getter_AddRefs(dirty_region));
mGeometry->Update(this, mGeometryUpdateFlags, getter_AddRefs(dirty_region));
mGeometryUpdateFlags = 0;

Просмотреть файл

@ -0,0 +1,169 @@
/* -*- 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
* Crocodile Clips Ltd..
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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_SVGGLYPHFRAME_H__
#define __NS_SVGGLYPHFRAME_H__
#include "nsSVGGeometryFrame.h"
#include "nsISVGGlyphGeometrySource.h"
#include "nsISVGGlyphFragmentLeaf.h"
#include "nsISVGChildFrame.h"
#include "nsISVGRendererRegion.h"
class nsISVGTextFrame;
typedef nsSVGGeometryFrame nsSVGGlyphFrameBase;
class nsSVGGlyphFrame : public nsSVGGlyphFrameBase,
public nsISVGGlyphGeometrySource, // : nsISVGGlyphMetricsSource
public nsISVGGlyphFragmentLeaf, // : nsISVGGlyphFragmentNode
public nsISVGChildFrame
{
protected:
friend nsIFrame*
NS_NewSVGGlyphFrame(nsIPresShell* aPresShell, nsIContent* aContent,
nsIFrame* parentFrame, nsStyleContext* aContext);
nsSVGGlyphFrame(nsStyleContext* aContext);
public:
// nsISupports interface:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef() { return 1; }
NS_IMETHOD_(nsrefcnt) Release() { return 1; }
// nsIFrame interface:
NS_IMETHOD
Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
NS_IMETHOD CharacterDataChanged(nsPresContext* aPresContext,
nsIContent* aChild,
PRBool aAppend);
NS_IMETHOD DidSetStyleContext();
NS_IMETHOD SetSelected(nsPresContext* aPresContext,
nsIDOMRange* aRange,
PRBool aSelected,
nsSpread aSpread);
NS_IMETHOD GetSelected(PRBool *aSelected) const;
NS_IMETHOD IsSelectable(PRBool* aIsSelectable, PRUint8* aSelectStyle) const;
/**
* Get the "type" of the frame
*
* @see nsLayoutAtoms::svgGlyphFrame
*/
virtual nsIAtom* GetType() const;
virtual PRBool IsFrameOfType(PRUint32 aFlags) const;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const
{
return MakeFrameName(NS_LITERAL_STRING("SVGGlyph"), aResult);
}
#endif
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
NS_IMETHOD_(already_AddRefed<nsISVGRendererRegion>) GetCoveredRegion();
NS_IMETHOD InitialUpdate();
NS_IMETHOD NotifyCanvasTMChanged(PRBool suppressInvalidation);
NS_IMETHOD NotifyRedrawSuspended();
NS_IMETHOD NotifyRedrawUnsuspended();
NS_IMETHOD SetMatrixPropagation(PRBool aPropagate) { return NS_OK; }
NS_IMETHOD SetOverrideCTM(nsIDOMSVGMatrix *aCTM) { return NS_ERROR_FAILURE; }
NS_IMETHOD GetBBox(nsIDOMSVGRect **_retval);
// nsISVGGeometrySource interface:
NS_IMETHOD GetCanvasTM(nsIDOMSVGMatrix * *aCTM);
virtual nsresult UpdateGraphic(PRUint32 aFlags,
PRBool suppressInvalidation = PR_FALSE);
// nsISVGGlyphMetricsSource interface:
NS_DECL_NSISVGGLYPHMETRICSSOURCE
// nsISVGGlyphGeometrySource interface:
NS_DECL_NSISVGGLYPHGEOMETRYSOURCE
// nsISVGGlyphFragmentLeaf interface:
NS_IMETHOD_(void) SetGlyphPosition(float x, float y);
NS_IMETHOD_(float) GetGlyphPositionX();
NS_IMETHOD_(float) GetGlyphPositionY();
NS_IMETHOD GetGlyphMetrics(nsISVGRendererGlyphMetrics** metrics);
NS_IMETHOD_(PRBool) IsStartOfChunk(); // == is new absolutely positioned chunk.
NS_IMETHOD_(void) GetAdjustedPosition(/* inout */ float &x, /* inout */ float &y);
NS_IMETHOD_(PRUint32) GetNumberOfChars();
NS_IMETHOD_(PRUint32) GetCharNumberOffset();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetX();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetY();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDx();
NS_IMETHOD_(already_AddRefed<nsIDOMSVGLengthList>) GetDy();
NS_IMETHOD_(PRUint16) GetTextAnchor();
NS_IMETHOD_(PRBool) IsAbsolutelyPositioned();
// nsISVGGlyphFragmentNode interface:
NS_IMETHOD_(nsISVGGlyphFragmentLeaf *) GetFirstGlyphFragment();
NS_IMETHOD_(nsISVGGlyphFragmentLeaf *) GetNextGlyphFragment();
NS_IMETHOD_(PRUint32) BuildGlyphFragmentTree(PRUint32 charNum, PRBool lastBranch);
NS_IMETHOD_(void) NotifyMetricsSuspended();
NS_IMETHOD_(void) NotifyMetricsUnsuspended();
NS_IMETHOD_(void) NotifyGlyphFragmentTreeSuspended();
NS_IMETHOD_(void) NotifyGlyphFragmentTreeUnsuspended();
protected:
void UpdateGeometry(PRUint32 flags, PRBool bRedraw,
PRBool suppressInvalidation);
void UpdateMetrics(PRUint32 flags);
void UpdateFragmentTree();
nsISVGTextFrame *GetTextFrame();
nsCOMPtr<nsISVGRendererGlyphGeometry> mGeometry;
nsCOMPtr<nsISVGRendererGlyphMetrics> mMetrics;
float mX, mY;
PRUint32 mGeometryUpdateFlags;
PRUint32 mMetricsUpdateFlags;
PRUint32 mCharOffset;
nsString mCharacterData;
PRPackedBool mFragmentTreeDirty;
};
#endif

Просмотреть файл

@ -39,9 +39,14 @@
#ifndef __NS_SVGGRADIENT_H__
#define __NS_SVGGRADIENT_H__
#include "nsISVGGradient.h"
#include "nsIURI.h"
#include "nsIContent.h"
#include "nscore.h"
class nsISVGGradient;
class nsIURI;
class nsIContent;
class nsIPresShell;
class nsStyleContext;
class nsIFrame;
nsresult NS_GetSVGGradient(nsISVGGradient** result,
nsIURI* aURI,

Просмотреть файл

@ -43,12 +43,12 @@
#include "nsIDOMSVGAnimTransformList.h"
#include "nsIDOMSVGTransformList.h"
#include "nsSVGMatrix.h"
#include "nsISVGGeometrySource.h"
#include "nsISVGGradient.h"
#include "nsIURI.h"
#include "nsIDOMSVGStopElement.h"
#include "nsSVGDefsFrame.h"
#include "nsSVGGradientElement.h"
#include "nsSVGGeometryFrame.h"
class nsSVGLinearGradientFrame;
class nsSVGRadialGradientFrame;
@ -522,25 +522,22 @@ nsSVGGradientFrame::GetGradientType(PRUint32 *aType)
NS_IMETHODIMP
nsSVGGradientFrame::GetGradientTransform(nsIDOMSVGMatrix **aGradientTransform,
nsISVGGeometrySource *aSource)
nsSVGGeometryFrame *aSource)
{
*aGradientTransform = nsnull;
nsCOMPtr<nsIDOMSVGMatrix> bboxTransform;
PRUint16 gradientUnits = GetGradientUnits();
if (gradientUnits == nsIDOMSVGGradientElement::SVG_GRUNITS_USERSPACEONUSE) {
nsIFrame *frame = nsnull;
CallQueryInterface(aSource, &frame);
// If this gradient is applied to text, our caller
// will be the glyph, which is not a container, so we
// need to get the parent
nsIAtom *callerType = frame->GetType();
nsIAtom *callerType = aSource->GetType();
if (callerType == nsGkAtoms::svgGlyphFrame)
mSourceContent = NS_STATIC_CAST(nsSVGElement*,
frame->GetContent()->GetParent());
aSource->GetContent()->GetParent());
else
mSourceContent = NS_STATIC_CAST(nsSVGElement*, frame->GetContent());
mSourceContent = NS_STATIC_CAST(nsSVGElement*, aSource->GetContent());
NS_ASSERTION(mSourceContent, "Can't get content for gradient");
}
else {

Просмотреть файл

@ -93,9 +93,12 @@ public:
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas);
// nsISVGGeometrySource interface:
NS_IMETHOD GetStrokePaintType(PRUint16 *aStrokePaintType);
NS_IMETHOD GetFillPaintType(PRUint16 *aFillPaintType);
// nsSVGGeometryFrame overload:
// Lie about our fill/stroke so hit detection works
virtual nsresult GetStrokePaintType() { return eStyleSVGPaintType_None; }
virtual nsresult GetFillPaintType() { return eStyleSVGPaintType_Color; }
// nsISVGPathGeometrySource mthods:
NS_IMETHOD GetHittestMask(PRUint16 *aHittestMask);
/**
@ -475,22 +478,6 @@ nsSVGImageFrame::ConvertFrame(gfxIImageFrame *aNewFrame)
// Lie about our fill/stroke so that hit detection works properly
/* readonly attribute unsigned short strokePaintType; */
NS_IMETHODIMP
nsSVGImageFrame::GetStrokePaintType(PRUint16 *aStrokePaintType)
{
*aStrokePaintType = nsISVGGeometrySource::PAINT_TYPE_NONE;
return NS_OK;
}
/* readonly attribute unsigned short fillPaintType; */
NS_IMETHODIMP
nsSVGImageFrame::GetFillPaintType(PRUint16 *aFillPaintType)
{
*aFillPaintType = nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR;
return NS_OK;
}
NS_IMETHODIMP
nsSVGImageFrame::GetHittestMask(PRUint16 *aHittestMask)
{
@ -588,7 +575,7 @@ NS_IMETHODIMP nsSVGImageListener::OnStopDecode(imgIRequest *aRequest,
return NS_ERROR_FAILURE;
mFrame->mSurfaceInvalid = PR_TRUE;
mFrame->UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_ALL);
mFrame->UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_ALL);
return NS_OK;
}
@ -600,7 +587,7 @@ NS_IMETHODIMP nsSVGImageListener::FrameChanged(imgIContainer *aContainer,
return NS_ERROR_FAILURE;
mFrame->mSurfaceInvalid = PR_TRUE;
mFrame->UpdateGraphic(nsISVGPathGeometrySource::UPDATEMASK_ALL);
mFrame->UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_ALL);
return NS_OK;
}

Просмотреть файл

@ -247,17 +247,10 @@ nsSVGMarkerFrame::GetCanvasTM()
mInUse2 = PR_TRUE;
// get our parent's tm and append local transform
nsCOMPtr<nsIDOMSVGMatrix> parentTM;
if (mMarkerParent) {
nsISVGGeometrySource *geometrySource;
mMarkerParent->QueryInterface(NS_GET_IID(nsISVGGeometrySource),
(void**)&geometrySource);
if (!geometrySource) {
NS_ERROR("invalid parent");
mInUse2 = PR_FALSE;
return nsnull;
}
geometrySource->GetCanvasTM(getter_AddRefs(parentTM));
mMarkerParent->GetCanvasTM(getter_AddRefs(parentTM));
} else {
// <svg:defs>
nsISVGContainerFrame *containerFrame;
@ -330,10 +323,7 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
nsCOMPtr<nsIDOMSVGMatrix> parentTransform, markerTransform, clipTransform;
nsCOMPtr<nsIDOMSVGMatrix> viewTransform;
nsISVGGeometrySource *parent;
CallQueryInterface(mMarkerParent, &parent);
if (parent)
parent->GetCanvasTM(getter_AddRefs(parentTransform));
mMarkerParent->GetCanvasTM(getter_AddRefs(parentTransform));
nsSVGMarkerElement *element = NS_STATIC_CAST(nsSVGMarkerElement*, mContent);
element->GetMarkerTransform(mStrokeWidth, mX, mY, mAngle,

Просмотреть файл

@ -1094,15 +1094,15 @@ nsSVGPathFrame::GetFlattenedPath(nsSVGPathData **data,
if (parent) {
mParent = parent;
GetGeometry()->Update(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM,
GetGeometry()->Update(this, nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM,
getter_AddRefs(dirty_region));
}
GetGeometry()->Flatten(data);
GetGeometry()->Flatten(this, data);
if (parent) {
mParent = oldParent;
GetGeometry()->Update(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM,
GetGeometry()->Update(this, nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM,
getter_AddRefs(dirty_region));
}

Просмотреть файл

@ -43,7 +43,6 @@
#include "nsISVGRenderer.h"
#include "nsISVGRendererRegion.h"
#include "nsISVGValueUtils.h"
#include "nsISVGGeometrySource.h"
#include "nsISVGContainerFrame.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
@ -82,8 +81,6 @@ struct nsSVGMarkerProperty {
nsSVGPathGeometryFrame::nsSVGPathGeometryFrame(nsStyleContext* aContext)
: nsSVGPathGeometryFrameBase(aContext),
mUpdateFlags(0),
mFillGradient(nsnull), mStrokeGradient(nsnull),
mFillPattern(nsnull), mStrokePattern(nsnull),
mPropagateTransform(PR_TRUE)
{
#ifdef DEBUG
@ -97,18 +94,6 @@ nsSVGPathGeometryFrame::~nsSVGPathGeometryFrame()
// printf("~nsSVGPathGeometryFrame %p\n", this);
#endif
if (mFillGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillGradient);
}
if (mStrokeGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokeGradient);
}
if (mFillPattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillPattern);
}
if (mStrokePattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokePattern);
}
if (GetStateBits() & NS_STATE_SVG_HAS_MARKERS) {
DeleteProperty(nsGkAtoms::marker);
}
@ -118,10 +103,7 @@ nsSVGPathGeometryFrame::~nsSVGPathGeometryFrame()
// nsISupports methods
NS_INTERFACE_MAP_BEGIN(nsSVGPathGeometryFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGGeometrySource)
NS_INTERFACE_MAP_ENTRY(nsISVGPathGeometrySource)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver)
NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame)
NS_INTERFACE_MAP_END_INHERITING(nsSVGPathGeometryFrameBase)
@ -154,7 +136,7 @@ nsSVGPathGeometryFrame::AttributeChanged(PRInt32 aNameSpaceID,
{
if (aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::transform)
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM);
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM);
return NS_OK;
}
@ -162,24 +144,8 @@ nsSVGPathGeometryFrame::AttributeChanged(PRInt32 aNameSpaceID,
NS_IMETHODIMP
nsSVGPathGeometryFrame::DidSetStyleContext()
{
// One of the styles that might have been changed are the urls that
// point to gradients, etc. Drop our cached values to those
if (mFillGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillGradient);
mFillGradient = nsnull;
}
if (mStrokeGradient) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokeGradient);
mStrokeGradient = nsnull;
}
if (mFillPattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mFillPattern);
mFillPattern = nsnull;
}
if (mStrokePattern) {
NS_REMOVE_SVGVALUE_OBSERVER(mStrokePattern);
mStrokePattern = nsnull;
}
nsSVGPathGeometryFrameBase::DidSetStyleContext();
nsSVGUtils::StyleEffects(this);
if (GetStateBits() & NS_STATE_SVG_HAS_MARKERS) {
@ -193,7 +159,7 @@ nsSVGPathGeometryFrame::DidSetStyleContext()
// style_hints don't map very well onto svg. Here seems to be the
// best place to deal with style changes:
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_ALL);
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_ALL);
return NS_OK;
}
@ -313,7 +279,7 @@ nsSVGPathGeometryFrame::PaintSVG(nsISVGRendererCanvas* canvas)
return NS_OK;
/* render */
GetGeometry()->Render(canvas);
GetGeometry()->Render(this, canvas);
nsISVGMarkable *markable;
CallQueryInterface(this, &markable);
@ -329,8 +295,7 @@ nsSVGPathGeometryFrame::PaintSVG(nsISVGRendererCanvas* canvas)
if (!mMarkerRegion)
mMarkerRegion = GetCoveredRegion();
float strokeWidth;
GetStrokeWidth(&strokeWidth);
float strokeWidth = GetStrokeWidth();
nsVoidArray marks;
markable->GetMarkPoints(&marks);
@ -362,7 +327,7 @@ nsSVGPathGeometryFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
// test for hit:
*hit = nsnull;
PRBool isHit;
GetGeometry()->ContainsPoint(x, y, &isHit);
GetGeometry()->ContainsPoint(this, x, y, &isHit);
if (isHit && nsSVGUtils::HitTestClip(this, x, y))
*hit = this;
@ -377,7 +342,7 @@ nsSVGPathGeometryFrame::GetCoveredRegion()
if (!GetGeometry())
return region;
GetGeometry()->GetCoveredRegion(&region);
GetGeometry()->GetCoveredRegion(this, &region);
nsISVGMarkable *markable;
CallQueryInterface(this, &markable);
@ -389,8 +354,7 @@ nsSVGPathGeometryFrame::GetCoveredRegion()
if (!markerEnd && !markerMid && !markerStart)
return region;
float strokeWidth;
GetStrokeWidth(&strokeWidth);
float strokeWidth = GetStrokeWidth();
nsVoidArray marks;
markable->GetMarkPoints(&marks);
@ -435,7 +399,7 @@ nsSVGPathGeometryFrame::GetCoveredRegion()
NS_IMETHODIMP
nsSVGPathGeometryFrame::InitialUpdate()
{
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_ALL);
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_ALL);
return NS_OK;
}
@ -443,7 +407,7 @@ nsSVGPathGeometryFrame::InitialUpdate()
NS_IMETHODIMP
nsSVGPathGeometryFrame::NotifyCanvasTMChanged(PRBool suppressInvalidation)
{
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_CANVAS_TM,
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM,
suppressInvalidation);
return NS_OK;
@ -460,7 +424,7 @@ NS_IMETHODIMP
nsSVGPathGeometryFrame::NotifyRedrawUnsuspended()
{
if (mUpdateFlags != 0)
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_NOTHING);
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_NOTHING);
return NS_OK;
}
@ -483,7 +447,7 @@ NS_IMETHODIMP
nsSVGPathGeometryFrame::GetBBox(nsIDOMSVGRect **_retval)
{
if (GetGeometry())
return GetGeometry()->GetBoundingBox(_retval);
return GetGeometry()->GetBoundingBox(this, _retval);
return NS_ERROR_FAILURE;
}
@ -506,53 +470,14 @@ nsSVGPathGeometryFrame::DidModifySVGObservable (nsISVGValue* observable,
{
nsSVGUtils::DidModifyEffects(this, observable, aModType);
nsISVGGradient *gradient;
CallQueryInterface(observable, &gradient);
if (gradient) {
// Yes, we need to handle this differently
if (mFillGradient == gradient) {
if (aModType == nsISVGValue::mod_die) {
mFillGradient = nsnull;
}
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_FILL_PAINT);
} else {
// No real harm in assuming a stroke gradient at this point
if (aModType == nsISVGValue::mod_die) {
mStrokeGradient = nsnull;
}
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT);
}
return NS_OK;
}
nsSVGPathGeometryFrameBase::DidModifySVGObservable(observable, aModType);
nsISVGFilterFrame *filter;
CallQueryInterface(observable, &filter);
if (filter) {
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT |
nsISVGGeometrySource::UPDATEMASK_FILL_PAINT);
return NS_OK;
}
nsISVGPattern *pval;
CallQueryInterface(observable, &pval);
if (pval) {
// Handle Patterns
if (mFillPattern == pval) {
if (aModType == nsISVGValue::mod_die) {
mFillPattern = nsnull;
}
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_FILL_PAINT);
} else {
// Assume stroke pattern
if (aModType == nsISVGValue::mod_die) {
mStrokePattern = nsnull;
}
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT);
}
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_STROKE_PAINT |
nsSVGGeometryFrame::UPDATEMASK_FILL_PAINT);
return NS_OK;
}
@ -565,7 +490,7 @@ nsSVGPathGeometryFrame::DidModifySVGObservable (nsISVGValue* observable,
GetProperty(nsGkAtoms::marker)),
this,
marker);
UpdateGraphic(nsISVGGeometrySource::UPDATEMASK_NOTHING);
UpdateGraphic(nsSVGGeometryFrame::UPDATEMASK_NOTHING);
return NS_OK;
}
@ -573,17 +498,7 @@ nsSVGPathGeometryFrame::DidModifySVGObservable (nsISVGValue* observable,
}
//----------------------------------------------------------------------
// nsISVGGeometrySource methods:
/* [noscript] readonly attribute nsPresContext presContext; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetPresContext(nsPresContext * *aPresContext)
{
// XXX gcc 3.2.2 requires the explicit 'nsSVGPathGeometryFrameBase::' qualification
*aPresContext = nsSVGPathGeometryFrameBase::GetPresContext();
NS_ADDREF(*aPresContext);
return NS_OK;
}
// nsSVGGeometryFrame methods:
/* readonly attribute nsIDOMSVGMatrix canvasTM; */
NS_IMETHODIMP
@ -623,274 +538,6 @@ nsSVGPathGeometryFrame::GetCanvasTM(nsIDOMSVGMatrix * *aCTM)
return NS_OK;
}
/* readonly attribute float strokeOpacity; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeOpacity(float *aStrokeOpacity)
{
*aStrokeOpacity = GetStyleSVG()->mStrokeOpacity;
return NS_OK;
}
/* readonly attribute float strokeWidth; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeWidth(float *aStrokeWidth)
{
*aStrokeWidth =
nsSVGUtils::CoordToFloat(nsSVGPathGeometryFrameBase::GetPresContext(),
mContent, GetStyleSVG()->mStrokeWidth);
return NS_OK;
}
/* void getStrokeDashArray ([array, size_is (count)] out float arr, out unsigned long count); */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
{
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
nsPresContext *presContext = nsSVGPathGeometryFrameBase::GetPresContext();
float totalLength = 0.0f;
*count = GetStyleSVG()->mStrokeDasharrayLength;
*arr = nsnull;
if (*count) {
*arr = (float *) nsMemory::Alloc(*count * sizeof(float));
if (*arr) {
for (PRUint32 i = 0; i < *count; i++) {
(*arr)[i] = nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
if ((*arr)[i] < 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
return NS_OK;
}
totalLength += (*arr)[i];
}
} else {
*count = 0;
return NS_ERROR_OUT_OF_MEMORY;
}
if (totalLength == 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
}
}
return NS_OK;
}
/* readonly attribute float strokeDashoffset; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeDashoffset(float *aStrokeDashoffset)
{
*aStrokeDashoffset =
nsSVGUtils::CoordToFloat(nsSVGPathGeometryFrameBase::GetPresContext(),
mContent, GetStyleSVG()->mStrokeDashoffset);
return NS_OK;
}
/* readonly attribute unsigned short strokeLinecap; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeLinecap(PRUint16 *aStrokeLinecap)
{
*aStrokeLinecap = GetStyleSVG()->mStrokeLinecap;
return NS_OK;
}
/* readonly attribute unsigned short strokeLinejoin; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeLinejoin(PRUint16 *aStrokeLinejoin)
{
*aStrokeLinejoin = GetStyleSVG()->mStrokeLinejoin;
return NS_OK;
}
/* readonly attribute float strokeMiterlimit; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeMiterlimit(float *aStrokeMiterlimit)
{
*aStrokeMiterlimit = GetStyleSVG()->mStrokeMiterlimit;
return NS_OK;
}
/* readonly attribute float fillOpacity; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetFillOpacity(float *aFillOpacity)
{
*aFillOpacity = GetStyleSVG()->mFillOpacity;
return NS_OK;
}
/* readonly attribute unsigned short fillRule; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetFillRule(PRUint16 *aFillRule)
{
*aFillRule = GetStyleSVG()->mFillRule;
return NS_OK;
}
/* readonly attribute unsigned short clipRule; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetClipRule(PRUint16 *aClipRule)
{
*aClipRule = GetStyleSVG()->mClipRule;
return NS_OK;
}
/* readonly attribute unsigned short strokePaintType; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokePaintType(PRUint16 *aStrokePaintType)
{
float strokeWidth;
GetStrokeWidth(&strokeWidth);
// cairo will stop rendering if stroke-width is less than or equal to zero
*aStrokePaintType = strokeWidth <= 0 ?
nsISVGGeometrySource::PAINT_TYPE_NONE :
GetStyleSVG()->mStroke.mType;
return NS_OK;
}
/* readonly attribute unsigned short strokePaintServerType; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokePaintServerType(PRUint16 *aStrokePaintServerType) {
return nsSVGUtils::GetPaintType(aStrokePaintServerType, GetStyleSVG()->mStroke, mContent,
nsSVGPathGeometryFrameBase::GetPresContext()->PresShell());
}
/* [noscript] readonly attribute nscolor strokePaint; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokePaint(nscolor *aStrokePaint)
{
*aStrokePaint = GetStyleSVG()->mStroke.mPaint.mColor;
return NS_OK;
}
/* [noscript] void GetStrokeGradient(nsISVGGradient **aGrad); */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokeGradient(nsISVGGradient **aGrad)
{
nsresult rv = NS_OK;
*aGrad = nsnull;
if (!mStrokeGradient) {
nsIURI *aServer;
aServer = GetStyleSVG()->mStroke.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGGradient(&mStrokeGradient, aServer, mContent,
nsSVGPathGeometryFrameBase::GetPresContext()->PresShell());
NS_ADD_SVGVALUE_OBSERVER(mStrokeGradient);
}
*aGrad = mStrokeGradient;
return rv;
}
/* [noscript] void GetStrokePattern(nsISVGPattern **aPat); */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetStrokePattern(nsISVGPattern **aPat)
{
nsresult rv = NS_OK;
*aPat = nsnull;
if (!mStrokePattern) {
nsIURI *aServer;
aServer = GetStyleSVG()->mStroke.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGPattern(&mStrokePattern, aServer, mContent,
nsSVGPathGeometryFrameBase::GetPresContext()->PresShell());
if (mStrokePattern)
NS_ADD_SVGVALUE_OBSERVER(mStrokePattern);
}
*aPat = mStrokePattern;
return rv;
}
/* readonly attribute unsigned short fillPaintType; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetFillPaintType(PRUint16 *aFillPaintType)
{
*aFillPaintType = GetStyleSVG()->mFill.mType;
return NS_OK;
}
/* readonly attribute unsigned short fillPaintServerType; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetFillPaintServerType(PRUint16 *aFillPaintServerType)
{
return nsSVGUtils::GetPaintType(aFillPaintServerType, GetStyleSVG()->mFill, mContent,
nsSVGPathGeometryFrameBase::GetPresContext()->PresShell());
}
/* [noscript] readonly attribute nscolor fillPaint; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetFillPaint(nscolor *aFillPaint)
{
*aFillPaint = GetStyleSVG()->mFill.mPaint.mColor;
return NS_OK;
}
/* [noscript] void GetFillGradient(nsISVGGradient **aGrad); */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetFillGradient(nsISVGGradient **aGrad)
{
nsresult rv = NS_OK;
*aGrad = nsnull;
if (!mFillGradient) {
nsIURI *aServer;
aServer = GetStyleSVG()->mFill.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the gradient
rv = NS_GetSVGGradient(&mFillGradient, aServer, mContent,
nsSVGPathGeometryFrameBase::GetPresContext()->PresShell());
NS_ADD_SVGVALUE_OBSERVER(mFillGradient);
}
*aGrad = mFillGradient;
return rv;
}
/* [noscript] void GetFillPattern(nsISVGPattern **aPat); */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetFillPattern(nsISVGPattern **aPat)
{
nsresult rv = NS_OK;
*aPat = nsnull;
if (!mFillPattern) {
nsIURI *aServer;
aServer = GetStyleSVG()->mFill.mPaint.mPaintServer;
if (aServer == nsnull)
return NS_ERROR_FAILURE;
// Now have the URI. Get the pattern
rv = NS_GetSVGPattern(&mFillPattern, aServer, mContent,
nsSVGPathGeometryFrameBase::GetPresContext()->PresShell());
if (mFillPattern)
NS_ADD_SVGVALUE_OBSERVER(mFillPattern);
}
*aPat = mFillPattern;
return rv;
}
/* [noscript] boolean isClipChild; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::IsClipChild(PRBool *_retval)
{
*_retval = PR_FALSE;
nsCOMPtr<nsIContent> node(mContent);
do {
if (node->Tag() == nsSVGAtoms::clipPath) {
*_retval = PR_TRUE;
break;
}
node = node->GetParent();
} while (node);
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
@ -973,7 +620,7 @@ nsSVGPathGeometryFrame::InitSVG()
outerSVGFrame->GetRenderer(getter_AddRefs(renderer));
if (!renderer) return NS_ERROR_FAILURE;
renderer->CreatePathGeometry(this, getter_AddRefs(mGeometry));
renderer->CreatePathGeometry(getter_AddRefs(mGeometry));
if (!mGeometry) return NS_ERROR_FAILURE;
@ -989,15 +636,16 @@ nsSVGPathGeometryFrame::GetGeometry()
return mGeometry;
}
void nsSVGPathGeometryFrame::UpdateGraphic(PRUint32 flags,
PRBool suppressInvalidation)
nsresult
nsSVGPathGeometryFrame::UpdateGraphic(PRUint32 flags,
PRBool suppressInvalidation)
{
mUpdateFlags |= flags;
nsISVGOuterSVGFrame *outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(this);
if (!outerSVGFrame) {
NS_ERROR("null outerSVGFrame");
return;
return NS_ERROR_FAILURE;
}
PRBool suspended;
@ -1005,12 +653,12 @@ void nsSVGPathGeometryFrame::UpdateGraphic(PRUint32 flags,
if (!suspended) {
nsCOMPtr<nsISVGRendererRegion> dirty_region;
if (GetGeometry())
GetGeometry()->Update(mUpdateFlags, getter_AddRefs(dirty_region));
GetGeometry()->Update(this, mUpdateFlags, getter_AddRefs(dirty_region));
mUpdateFlags = 0;
if (suppressInvalidation)
return;
return NS_OK;
nsCOMPtr<nsISVGRendererRegion> filter_region;
nsSVGUtils::FindFilterInvalidation(this,
@ -1034,7 +682,7 @@ void nsSVGPathGeometryFrame::UpdateGraphic(PRUint32 flags,
mMarkerRegion = GetCoveredRegion();
if (mMarkerRegion)
outerSVGFrame->InvalidateRegion(mMarkerRegion, PR_TRUE);
return;
return NS_OK;
}
}
@ -1042,6 +690,8 @@ void nsSVGPathGeometryFrame::UpdateGraphic(PRUint32 flags,
outerSVGFrame->InvalidateRegion(dirty_region, PR_TRUE);
}
}
return NS_OK;
}

Просмотреть файл

@ -50,6 +50,7 @@
#include "nsSVGGradient.h"
#include "nsSVGPattern.h"
#include "nsLayoutAtoms.h"
#include "nsSVGGeometryFrame.h"
class nsPresContext;
class nsIDOMSVGMatrix;
@ -58,11 +59,9 @@ class nsISVGMarkerFrame;
class nsISVGFilterFrame;
struct nsSVGMarkerProperty;
typedef nsFrame nsSVGPathGeometryFrameBase;
typedef nsSVGGeometryFrame nsSVGPathGeometryFrameBase;
class nsSVGPathGeometryFrame : public nsSVGPathGeometryFrameBase,
public nsISVGValueObserver,
public nsSupportsWeakReference,
public nsISVGPathGeometrySource,
public nsISVGChildFrame
{
@ -73,8 +72,8 @@ protected:
public:
// nsISupports interface:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) AddRef() { return 1; }
NS_IMETHOD_(nsrefcnt) Release() { return 1; }
// nsIFrame interface:
NS_IMETHOD
@ -103,6 +102,13 @@ public:
}
#endif
// nsISVGPathGeometrySource interface:
NS_IMETHOD GetHittestMask(PRUint16 *aHittestMask);
NS_IMETHOD GetShapeRendering(PRUint16 *aShapeRendering);
// nsISVGGeometrySource interface:
NS_IMETHOD GetCanvasTM(nsIDOMSVGMatrix * *aCTM);
protected:
// nsISVGValueObserver
NS_IMETHOD WillModifySVGObservable(nsISVGValue* observable,
@ -122,21 +128,12 @@ protected:
NS_IMETHOD SetOverrideCTM(nsIDOMSVGMatrix *aCTM);
NS_IMETHOD GetBBox(nsIDOMSVGRect **_retval);
// nsISupportsWeakReference
// implementation inherited from nsSupportsWeakReference
// nsISVGGeometrySource interface:
NS_DECL_NSISVGGEOMETRYSOURCE
// nsISVGPathGeometrySource interface:
NS_IMETHOD GetHittestMask(PRUint16 *aHittestMask);
NS_IMETHOD GetShapeRendering(PRUint16 *aShapeRendering);
// to be implemented by subclass:
//NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder) = 0;
// nsISVGGeometrySource interface:
virtual nsresult UpdateGraphic(PRUint32 flags,
PRBool suppressInvalidation = PR_FALSE);
protected:
NS_IMETHOD InitSVG();
void UpdateGraphic(PRUint32 flags, PRBool suppressInvalidation = PR_FALSE);
nsISVGRendererPathGeometry *GetGeometry();
nsCOMPtr<nsISVGRendererRegion> mMarkerRegion;
@ -148,15 +145,11 @@ private:
void GetMarkerFromStyle(nsISVGMarkerFrame **aResult,
nsSVGMarkerProperty *property,
nsIURI *aURI);
void UpdateMarkerProperty();
void UpdateMarkerProperty();
nsCOMPtr<nsISVGRendererPathGeometry> mGeometry;
PRUint32 mUpdateFlags;
nsISVGGradient* mFillGradient;
nsISVGGradient* mStrokeGradient;
nsCOMPtr<nsIDOMSVGMatrix> mOverrideCTM;
nsISVGPattern* mFillPattern;
nsISVGPattern* mStrokePattern;
PRPackedBool mPropagateTransform;
};

Просмотреть файл

@ -39,15 +39,17 @@
#ifndef __NS_SVGPATTERN_H__
#define __NS_SVGPATTERN_H__
#include "nsISVGPattern.h"
#include "nsIURI.h"
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nscore.h"
class nsISVGPattern;
class nsIURI;
class nsIContent;
class nsIPresShell;
nsresult NS_GetSVGPattern(nsISVGPattern** result,
nsIURI* aURI,
nsIContent* aContent,
nsIPresShell* aPresShell);
nsIURI* aURI,
nsIContent* aContent,
nsIPresShell* aPresShell);
#endif // __NS_SVGPATTERN_H__

Просмотреть файл

@ -67,7 +67,6 @@
#include "nsIDOMSVGRect.h"
#include "nsSVGMatrix.h"
#include "nsSVGRect.h"
#include "nsISVGGeometrySource.h"
#include "nsISVGPattern.h"
#include "nsIURI.h"
#include "nsIContent.h"
@ -82,6 +81,7 @@
#include "nsISVGContainerFrame.h"
#include "nsSVGDefsFrame.h"
#include "nsSVGPatternElement.h"
#include "nsSVGGeometryFrame.h"
typedef nsSVGDefsFrame nsSVGPatternFrameBase;
@ -182,7 +182,7 @@ protected:
nsresult GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
nsIDOMSVGRect **aBBox,
nsSVGElement **aContent,
nsISVGGeometrySource *aSource);
nsSVGGeometryFrame *aSource);
//
@ -192,7 +192,7 @@ private:
// this is a *temporary* reference to the frame of the element currently
// referencing our pattern. This must be termporary because different
// referencing frames will all reference this one fram
nsISVGGeometrySource *mSource;
nsSVGGeometryFrame *mSource;
nsCOMPtr<nsIDOMSVGMatrix> mCTM;
protected:
@ -332,15 +332,9 @@ nsSVGPatternFrame::GetCanvasTM() {
// Yes, use it!
mSource->GetCanvasTM(&rCTM);
} else {
// No, we'll use our content parent, then
nsCOMPtr<nsISVGGeometrySource> aSource = do_QueryInterface(mParent);
if (aSource) {
aSource->GetCanvasTM(&rCTM);
} else {
// OK, we have no content parent, which means that we're
// not part of the document tree. Return an identity matrix?
NS_NewSVGMatrix(&rCTM, 1.0f,0.0f,0.0f,1.0f,0.0f,0.0f);
}
// No, return an identity
// We get here when geometry in the <pattern> container is updated
NS_NewSVGMatrix(&rCTM);
}
}
return rCTM;
@ -371,7 +365,8 @@ nsSVGPatternFrame::GetBBox(nsIDOMSVGRect **aRect) {
} else {
if (mSource) {
// Yes, use it!
nsCOMPtr<nsISVGChildFrame> callerSVGFrame = do_QueryInterface(mSource);
nsCOMPtr<nsISVGChildFrame> callerSVGFrame =
do_QueryInterface(NS_STATIC_CAST(nsIFrame*, mSource));
if (callerSVGFrame) {
return callerSVGFrame->GetBBox(aRect);
}
@ -393,7 +388,7 @@ NS_IMETHODIMP
nsSVGPatternFrame::PaintPattern(nsISVGRendererCanvas* canvas,
nsISVGRendererSurface** surface,
nsIDOMSVGMatrix** patternMatrix,
nsISVGGeometrySource *aSource)
nsSVGGeometryFrame *aSource)
{
/*
@ -941,35 +936,22 @@ nsresult
nsSVGPatternFrame::GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
nsIDOMSVGRect **aBBox,
nsSVGElement **aContent,
nsISVGGeometrySource *aSource)
nsSVGGeometryFrame *aSource)
{
*aCTM = nsnull;
*aBBox = nsnull;
*aContent = nsnull;
// Begin by getting all of our pointers and references to our
// calling geometry
nsCOMPtr<nsISVGChildFrame> callerSVGFrame = do_QueryInterface(aSource);
NS_ASSERTION(callerSVGFrame,"Caller is not an nsISVGChildFrame!");
if (!callerSVGFrame)
return NS_ERROR_FAILURE;
nsIFrame *callerFrame;
CallQueryInterface(callerSVGFrame, &callerFrame);
NS_ASSERTION(callerFrame,"Caller is not an nsIFrame!");
if (!callerFrame)
return NS_ERROR_FAILURE;
// Make sure the callerContent is an SVG element. If we are attempting
// to paint a pattern for text, then the content will be the #text, so we
// actually want the parent, which should be the <svg:text> or <svg:tspan>
// element.
nsIAtom *callerType = callerFrame->GetType();
nsIAtom *callerType = aSource->GetType();
if (callerType == nsLayoutAtoms::svgGlyphFrame) {
*aContent = NS_STATIC_CAST(nsSVGElement*,
callerFrame->GetContent()->GetParent());
aSource->GetContent()->GetParent());
} else {
*aContent = NS_STATIC_CAST(nsSVGElement*, callerFrame->GetContent());
*aContent = NS_STATIC_CAST(nsSVGElement*, aSource->GetContent());
}
NS_ASSERTION(aContent,"Caller does not have any content!");
if (!aContent)
@ -977,6 +959,8 @@ nsSVGPatternFrame::GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
// Get the calling geometry's bounding box. This
// will be in *device coordinates*
nsISVGChildFrame *callerSVGFrame;
CallQueryInterface(aSource, &callerSVGFrame);
callerSVGFrame->GetBBox(aBBox);
// Sanity check
{

Просмотреть файл

@ -49,7 +49,6 @@
#include "nsStyleStruct.h"
#include "nsIPresShell.h"
#include "nsSVGUtils.h"
#include "nsISVGGeometrySource.h"
#include "nsISVGGlyphFragmentLeaf.h"
#include "nsISVGRendererGlyphMetrics.h"
#include "nsNetUtil.h"
@ -78,6 +77,7 @@
#include "nsSVGLength2.h"
#include "nsGenericElement.h"
#include "nsAttrValue.h"
#include "nsSVGGeometryFrame.h"
struct nsSVGFilterProperty {
nsCOMPtr<nsISVGRendererRegion> mFilterRegion;
@ -188,7 +188,7 @@ nsresult nsSVGUtils::GetPaintType(PRUint16 *aPaintType, const nsStyleSVGPaint& a
{
*aPaintType = aPaint.mType;
// If the type is a Paint Server, determine what kind
if (*aPaintType == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (*aPaintType == eStyleSVGPaintType_Server) {
nsIURI *server = aPaint.mPaint.mPaintServer;
if (server == nsnull)
return NS_ERROR_FAILURE;
@ -203,9 +203,9 @@ nsresult nsSVGUtils::GetPaintType(PRUint16 *aPaintType, const nsStyleSVGPaint& a
// Finally, figure out what type it is
if (aFrame->GetType() == nsLayoutAtoms::svgLinearGradientFrame ||
aFrame->GetType() == nsLayoutAtoms::svgRadialGradientFrame)
*aPaintType = nsISVGGeometrySource::PAINT_TYPE_GRADIENT;
*aPaintType = nsSVGGeometryFrame::PAINT_TYPE_GRADIENT;
else if (aFrame->GetType() == nsLayoutAtoms::svgPatternFrame)
*aPaintType = nsISVGGeometrySource::PAINT_TYPE_PATTERN;
*aPaintType = nsSVGGeometryFrame::PAINT_TYPE_PATTERN;
else
return NS_ERROR_FAILURE;
}
@ -729,18 +729,14 @@ nsSVGUtils::GetCanvasTM(nsIFrame *aFrame)
return containerFrame->GetCanvasTM();
}
nsISVGGeometrySource *geometrySource = nsnull;
CallQueryInterface(aFrame, &geometrySource);
if (geometrySource) {
nsCOMPtr<nsIDOMSVGMatrix> matrix;
nsIDOMSVGMatrix *retval;
geometrySource->GetCanvasTM(getter_AddRefs(matrix));
retval = matrix.get();
NS_IF_ADDREF(retval);
return retval;
}
return nsnull;
nsSVGGeometryFrame *geometryFrame = NS_STATIC_CAST(nsSVGGeometryFrame*,
aFrame);
nsCOMPtr<nsIDOMSVGMatrix> matrix;
nsIDOMSVGMatrix *retval;
geometryFrame->GetCanvasTM(getter_AddRefs(matrix));
retval = matrix.get();
NS_IF_ADDREF(retval);
return retval;
}
void

Просмотреть файл

@ -45,7 +45,6 @@ MODULE = layout
XPIDL_MODULE = gksvgrenderer
XPIDLSRCS = \
nsISVGGeometrySource.idl \
nsISVGGlyphGeometrySource.idl \
nsISVGGlyphMetricsSource.idl \
nsISVGGradient.idl \

Просмотреть файл

Просмотреть файл

@ -39,6 +39,8 @@
#include "nsISVGGlyphMetricsSource.idl"
native nscolor(nscolor);
interface nsISVGRendererGlyphMetrics;
/**

Просмотреть файл

@ -46,7 +46,7 @@ struct nsSVGCharacterPosition {
};
%}
#include "nsISVGGeometrySource.idl"
#include "nsISupports.idl"
native nsFont(nsFont);
[ptr] native nsSVGCharacterPosition(nsSVGCharacterPosition);
@ -70,8 +70,8 @@ native nsFont(nsFont);
*
* @nosubgrouping
*/
[uuid(bcd7ce03-9f17-4af1-9763-f44a323695e3)]
interface nsISVGGlyphMetricsSource : nsISVGGeometrySource
[uuid(b412d1ed-6e70-4078-8335-dee9f33c7e4a)]
interface nsISVGGlyphMetricsSource : nsISupports
{
/**
* @name Font

Просмотреть файл

@ -1,109 +0,0 @@
/* -*- Mode: IDL; 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
* Crocodile Clips Ltd.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scooter Morris <scootermorris@comcast.net> (original author)
*
* 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 ***** */
#include "nsISupports.idl"
%{C++
#include "nsColor.h"
%}
native nscolor(nscolor);
interface nsIDOMSVGMatrix;
interface nsISVGLinearGradient;
interface nsISVGRadialGradient;
interface nsIFrame;
interface nsISVGGeometrySource;
/**
* \addtogroup rendering_backend_interfaces Rendering Backend Interfaces
* @{
*/
/**
* Describes the 'gradient' objects (either linear or a radial) to the
* rendering backends.
*
* @nosubgrouping
*/
[uuid(0f43d022-03b9-4d0f-81b2-14881ac11831)]
interface nsISVGGradient : nsISupports
{
const unsigned long SVG_UNKNOWN_GRADIENT = 0;
const unsigned long SVG_LINEAR_GRADIENT = 1;
const unsigned long SVG_RADIAL_GRADIENT = 2;
readonly attribute PRUint32 gradientType;
readonly attribute PRUint16 spreadMethod;
void GetStopCount(out PRUint32 aStopCount);
void GetStopOffset(in PRInt32 aIndex, out float aOffset);
void GetStopColor(in PRInt32 aIndex, out nscolor aStopColor);
void GetStopOpacity(in PRInt32 aIndex, out float aStopOpacity);
void GetGradientTransform(out nsIDOMSVGMatrix retval,
in nsISVGGeometrySource aSource);
/** @} */
};
[uuid(995ad9e6-6bb1-47c5-b402-fc93ce12f5e7)]
interface nsISVGLinearGradient : nsISupports
{
readonly attribute float X1;
readonly attribute float X2;
readonly attribute float Y1;
readonly attribute float Y2;
/** @} */
};
[uuid(446435ff-6699-4b4d-85c1-09c18145f5ce)]
interface nsISVGRadialGradient : nsISupports
{
readonly attribute float Cx;
readonly attribute float Cy;
readonly attribute float R;
readonly attribute float Fx;
readonly attribute float Fy;
/** @} */
};
/** @} */

Просмотреть файл

@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISVGGeometrySource.idl"
#include "nsISupports.idl"
interface nsISVGRendererPathBuilder;
@ -67,8 +67,8 @@ interface nsISVGRendererPathBuilder;
[ptr] native cairo_t(cairo_t);
[uuid(da4a0226-0d97-4e7f-9bbb-d61c4977441c)]
interface nsISVGPathGeometrySource : nsISVGGeometrySource
[uuid(ef6ae87f-de79-4c86-a93e-9f4d243ea676)]
interface nsISVGPathGeometrySource : nsISupports
{
/**

Просмотреть файл

@ -1,85 +0,0 @@
/* -*- Mode: IDL; 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):
*
* 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 ***** */
#include "nsISupports.idl"
%{C++
struct nsRect;
%}
[ref] native nsRectRef(nsRect);
interface nsIDOMSVGMatrix;
interface nsIFrame;
interface nsISVGGeometrySource;
interface nsISVGRendererCanvas;
interface nsISVGRendererSurface;
/**
* \addtogroup rendering_backend_interfaces Rendering Backend Interfaces
* @{
*/
/**
* Describes the 'pattern' objects to the
* rendering backends.
*
* @nosubgrouping
*/
[uuid(343ea464-a699-4bc6-9b5b-c2d470bd6262)]
interface nsISVGPattern : nsISupports
{
readonly attribute PRUint16 patternUnits;
readonly attribute PRUint16 patternContentUnits;
readonly attribute float X;
readonly attribute float Y;
readonly attribute float Width;
readonly attribute float Height;
void GetPatternTransform(out nsIDOMSVGMatrix retval);
void PaintPattern(in nsISVGRendererCanvas canvas,
out nsISVGRendererSurface surface,
out nsIDOMSVGMatrix patternMatrix,
in nsISVGGeometrySource aSource);
/** @} */
};
/** @} */

Просмотреть файл

@ -76,20 +76,17 @@ interface nsPresContext;
* cross-platform libart engine
* ("@mozilla.org/svg/renderer;1?tech=LIBART").
*/
[scriptable, uuid(14e914e0-f283-4fd0-9d71-d3e842927007)]
[scriptable, uuid(52da7bce-b3aa-477f-8eaf-d38a86ea6b30)]
interface nsISVGRenderer : nsISupports
{
// void Init(in nsPresContext presContext);
/**
* Create a rendering engine-native path geometry object for the
* source object given by 'src'.
* Create a rendering engine-native path geometry object.
*
* @param src The source object describing the path for which
* this object is being created.
* @return A rendering engine-native path geometry object.
*/
nsISVGRendererPathGeometry createPathGeometry(in nsISVGPathGeometrySource src);
nsISVGRendererPathGeometry createPathGeometry();
/**
* Create a rendering engine-native glyph metrics object for the
@ -102,14 +99,11 @@ interface nsISVGRenderer : nsISupports
nsISVGRendererGlyphMetrics createGlyphMetrics(in nsISVGGlyphMetricsSource src);
/**
* Create a rendering engine-native glyph geometry object for the
* source object given by 'src'.
* Create a rendering engine-native glyph geometry object.
*
* @param src The source object describing the glyph for which
* this object is being created.
* @return A rendering engine-native glyph geometry object.
*/
nsISVGRendererGlyphGeometry createGlyphGeometry(in nsISVGGlyphGeometrySource src);
nsISVGRendererGlyphGeometry createGlyphGeometry();
/**
* Create a rendering engine-native canvas object for the

Просмотреть файл

@ -42,6 +42,7 @@ interface nsISVGRendererRegion;
interface nsISVGRendererGlyphMetrics;
interface nsISVGRendererCanvas;
interface nsIDOMSVGRect;
interface nsSVGGlyphFrame;
/**
* \addtogroup renderer_interfaces Rendering Engine Interfaces
@ -63,7 +64,7 @@ interface nsIDOMSVGRect;
* glyph rendering and hit-testing for the (composite) glyph described
* by the nsISVGGlyphGeometrySource members.
*/
[scriptable, uuid(e2b739d0-8415-4f36-982c-3579876e1435)]
[uuid(c4bb4669-563c-4c32-b499-e7b71fed4914)]
interface nsISVGRendererGlyphGeometry : nsISupports
{
/**
@ -71,7 +72,7 @@ interface nsISVGRendererGlyphGeometry : nsISupports
*
* @param canvas The canvas to render to.
*/
void render(in nsISVGRendererCanvas canvas);
void render(in nsSVGGlyphFrame source, in nsISVGRendererCanvas canvas);
/**
* Called by this object's corresponding nsISVGGlyphGeometrySource
@ -82,7 +83,8 @@ interface nsISVGRendererGlyphGeometry : nsISupports
* constants defined in nsISVGGlyphGeometrySource.
* @return Region that needs to be redrawn.
*/
nsISVGRendererRegion update(in unsigned long updatemask);
nsISVGRendererRegion update(in nsSVGGlyphFrame source,
in unsigned long updatemask);
/**
* Get a region object describing the area covered with paint by
@ -90,7 +92,7 @@ interface nsISVGRendererGlyphGeometry : nsISupports
*
* @return Covered region.
*/
nsISVGRendererRegion getCoveredRegion();
nsISVGRendererRegion getCoveredRegion(in nsSVGGlyphFrame source);
/**
* Hit-testing method. Does this glyph geometry (with all relevant
@ -102,12 +104,12 @@ interface nsISVGRendererGlyphGeometry : nsISupports
* @return PR_TRUE if the glyph geometry contains the point,
* PR_FALSE otherwise.
*/
boolean containsPoint(in float x, in float y);
boolean containsPoint(in nsSVGGlyphFrame source, in float x, in float y);
/**
* Transformed bounding box (does not include stroke width)
*/
readonly attribute nsIDOMSVGRect boundingBox;
void getBoundingBox(in nsSVGGlyphFrame source, out nsIDOMSVGRect box);
};
/** @} */

Просмотреть файл

@ -42,6 +42,7 @@ interface nsISVGRendererRegion;
interface nsISVGRendererCanvas;
interface nsIDOMSVGRect;
interface nsSVGPathData;
interface nsSVGPathGeometryFrame;
/**
* \addtogroup renderer_interfaces Rendering Engine Interfaces
@ -63,7 +64,7 @@ interface nsSVGPathData;
* provide rendering, hit-testing and metrics for the path described
* by the nsISVGPathGeometrySource members.
*/
[scriptable, uuid(95f9e432-90e6-48c1-a242-5346517b93d1)]
[uuid(4c207f7c-270a-47de-b0c4-59a00a66bdb9)]
interface nsISVGRendererPathGeometry : nsISupports
{
/**
@ -71,7 +72,8 @@ interface nsISVGRendererPathGeometry : nsISupports
*
* @param canvas The canvas to render to.
*/
void render(in nsISVGRendererCanvas canvas);
void render(in nsSVGPathGeometryFrame source,
in nsISVGRendererCanvas canvas);
/**
* Called by this object's corresponding nsISVGPathGeometrySource as
@ -82,7 +84,8 @@ interface nsISVGRendererPathGeometry : nsISupports
* constants defined in nsISVGPathGeometrySource.
* @return Region that needs to be redrawn.
*/
nsISVGRendererRegion update(in unsigned long updatemask);
nsISVGRendererRegion update(in nsSVGPathGeometryFrame source,
in unsigned long updatemask);
/**
* Get a region object describing the area covered with paint by
@ -90,7 +93,7 @@ interface nsISVGRendererPathGeometry : nsISupports
*
* @return Covered region.
*/
nsISVGRendererRegion getCoveredRegion();
nsISVGRendererRegion getCoveredRegion(in nsSVGPathGeometryFrame source);
/**
* Hit-testing method. Does this path geometry (with all relevant
@ -103,17 +106,21 @@ interface nsISVGRendererPathGeometry : nsISupports
* @return PR_TRUE if the path geometry contains the point,
* PR_FALSE otherwise.
*/
boolean containsPoint(in float x, in float y);
boolean containsPoint(in nsSVGPathGeometryFrame source,
in float x, in float y);
/**
* Bounding box (does not include stroke width)
*/
/*
readonly attribute nsIDOMSVGRect boundingBox;
*/
void getBoundingBox(in nsSVGPathGeometryFrame source, out nsIDOMSVGRect box);
/*
* Flattened path
*/
void flatten(out nsSVGPathData data);
void flatten(in nsSVGPathGeometryFrame source, out nsSVGPathData data);
};
/** @} */

Просмотреть файл

@ -91,7 +91,10 @@ CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
LOCAL_INCLUDES = \
-I$(topsrcdir)/gfx/src \
$(NULL)
-I$(topsrcdir)/layout/generic \
-I$(topsrcdir)/layout/svg/base/src \
-I$(topsrcdir)/layout/xul/base/src \
$(NULL)
ifdef MOZ_ENABLE_GTK
LOCAL_INCLUDES += -I$(topsrcdir)/gfx/src/gtk

Просмотреть файл

@ -64,6 +64,7 @@
#include "nsIDOMSVGRect.h"
#include "nsSVGTypeCIDs.h"
#include "nsIComponentManager.h"
#include "nsSVGGlyphFrame.h"
extern cairo_surface_t *gSVGCairoDummySurface;
@ -78,13 +79,10 @@ extern cairo_surface_t *gSVGCairoDummySurface;
class nsSVGCairoGlyphGeometry : public nsISVGRendererGlyphGeometry
{
protected:
friend nsresult NS_NewSVGCairoGlyphGeometry(nsISVGRendererGlyphGeometry **result,
nsISVGGlyphGeometrySource *src);
friend nsresult NS_NewSVGCairoGlyphGeometry(nsISVGRendererGlyphGeometry **result);
nsSVGCairoGlyphGeometry(nsISVGGlyphGeometrySource* src);
~nsSVGCairoGlyphGeometry();
nsresult GetGlobalTransform(cairo_t *ctx, nsISVGCairoCanvas* aCanvas);
nsresult GetGlobalTransform(nsSVGGlyphFrame *aSource,
cairo_t *ctx, nsISVGCairoCanvas* aCanvas);
public:
// nsISupports interface:
@ -93,9 +91,6 @@ public:
// nsISVGRendererGlyphGeometry interface:
NS_DECL_NSISVGRENDERERGLYPHGEOMETRY
protected:
nsISVGGlyphGeometrySource *mSource;
private:
nsCOMPtr<nsISVGRendererRegion> mCoveredRegion;
};
@ -105,20 +100,10 @@ private:
//----------------------------------------------------------------------
// implementation:
nsSVGCairoGlyphGeometry::nsSVGCairoGlyphGeometry(nsISVGGlyphGeometrySource* src)
: mSource(src)
{
}
nsSVGCairoGlyphGeometry::~nsSVGCairoGlyphGeometry()
{
}
nsresult
NS_NewSVGCairoGlyphGeometry(nsISVGRendererGlyphGeometry **result,
nsISVGGlyphGeometrySource *src)
NS_NewSVGCairoGlyphGeometry(nsISVGRendererGlyphGeometry **result)
{
*result = new nsSVGCairoGlyphGeometry(src);
*result = new nsSVGCairoGlyphGeometry;
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*result);
@ -159,21 +144,22 @@ NS_INTERFACE_MAP_END
/** Implements void render(in nsISVGRendererCanvas canvas); */
NS_IMETHODIMP
nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
nsSVGCairoGlyphGeometry::Render(nsSVGGlyphFrame *aSource,
nsISVGRendererCanvas *canvas)
{
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(canvas);
NS_ASSERTION(cairoCanvas, "wrong svg render context for geometry!");
if (!cairoCanvas) return NS_ERROR_FAILURE;
nsAutoString text;
mSource->GetCharacterData(text);
aSource->GetCharacterData(text);
if (!text.Length())
return NS_OK;
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
if (NS_FAILED(aSource->GetCharacterPosition(getter_Transfers(cp))))
return NS_ERROR_FAILURE;
cairo_t *ctx = cairoCanvas->GetContext();
@ -182,7 +168,7 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
nsCOMPtr<nsISVGCairoGlyphMetrics> metrics;
{
nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;
mSource->GetMetrics(getter_AddRefs(xpmetrics));
aSource->GetMetrics(getter_AddRefs(xpmetrics));
metrics = do_QueryInterface(xpmetrics);
NS_ASSERTION(metrics, "wrong metrics object!");
if (!metrics)
@ -200,7 +186,7 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
cairo_get_matrix(ctx, &matrix);
}
if (NS_FAILED(GetGlobalTransform(ctx, cairoCanvas))) {
if (NS_FAILED(GetGlobalTransform(aSource, ctx, cairoCanvas))) {
if (renderMode == nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL)
cairo_restore(ctx);
return NS_ERROR_FAILURE;
@ -210,15 +196,13 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
float x,y;
if (!cp) {
mSource->GetX(&x);
mSource->GetY(&y);
aSource->GetX(&x);
aSource->GetY(&y);
cairo_move_to(ctx, x, y);
}
if (renderMode != nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL) {
PRUint16 rule;
mSource->GetClipRule(&rule);
if (rule == nsISVGGeometrySource::FILL_RULE_EVENODD)
if (aSource->GetClipRule() == NS_STYLE_FILL_RULE_EVENODD)
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_WINDING);
@ -231,25 +215,23 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
}
PRBool hasFill = PR_FALSE;
PRUint16 filltype;
mSource->GetFillPaintType(&filltype);
PRUint16 filltype = aSource->GetFillPaintType();
PRUint16 fillServerType = 0;
if (filltype != nsISVGGeometrySource::PAINT_TYPE_NONE) {
if (filltype != eStyleSVGPaintType_None) {
hasFill = PR_TRUE;
if (filltype == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (NS_FAILED(mSource->GetFillPaintServerType(&fillServerType)))
if (filltype == eStyleSVGPaintType_Server) {
if (NS_FAILED(aSource->GetFillPaintServerType(&fillServerType)))
hasFill = PR_FALSE;
}
}
PRBool hasStroke = PR_FALSE;
PRUint16 stroketype;
mSource->GetStrokePaintType(&stroketype);
PRUint16 stroketype = aSource->GetStrokePaintType();
PRUint16 strokeServerType = 0;
if (stroketype != nsISVGGeometrySource::PAINT_TYPE_NONE) {
if (stroketype != eStyleSVGPaintType_None) {
hasStroke = PR_TRUE;
if (stroketype == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (NS_FAILED(mSource->GetStrokePaintServerType(&strokeServerType)))
if (stroketype == eStyleSVGPaintType_Server) {
if (NS_FAILED(aSource->GetStrokePaintServerType(&strokeServerType)))
hasStroke = PR_FALSE;
}
}
@ -260,39 +242,28 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
}
if (hasFill) {
nscolor rgb;
mSource->GetFillPaint(&rgb);
float opacity;
mSource->GetFillOpacity(&opacity);
aSource->SetupCairoFill(ctx);
cairo_set_source_rgba(ctx,
NS_GET_R(rgb)/255.0,
NS_GET_G(rgb)/255.0,
NS_GET_B(rgb)/255.0,
opacity);
if (filltype == nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR) {
if (filltype == eStyleSVGPaintType_Color) {
LOOP_CHARS(cairo_show_text)
} else if (filltype == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (fillServerType == nsISVGGeometrySource::PAINT_TYPE_GRADIENT) {
} else if (filltype == eStyleSVGPaintType_Server) {
if (fillServerType == nsSVGGeometryFrame::PAINT_TYPE_GRADIENT) {
nsISVGGradient *aGrad;
mSource->GetFillGradient(&aGrad);
aSource->GetFillGradient(&aGrad);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, mSource);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, aSource);
if (gradient) {
cairo_set_source(ctx, gradient);
LOOP_CHARS(cairo_show_text)
cairo_pattern_destroy(gradient);
}
} else if (fillServerType == nsISVGGeometrySource::PAINT_TYPE_PATTERN) {
} else if (fillServerType == nsSVGGeometryFrame::PAINT_TYPE_PATTERN) {
nsISVGPattern *aPat;
mSource->GetFillPattern(&aPat);
aSource->GetFillPattern(&aPat);
// Paint the pattern -- note that because we will call back into the
// layout layer to paint, we need to pass the canvas, not just the context
nsISVGGeometrySource *aGsource;
CallQueryInterface(mSource, &aGsource);
nsCOMPtr<nsISVGRendererSurface> patSurface;
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, aGsource, getter_AddRefs(patSurface));
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, aSource, getter_AddRefs(patSurface));
if (pattern) {
cairo_set_source(ctx, pattern);
LOOP_CHARS(cairo_show_text)
@ -307,89 +278,30 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
cairo_move_to(ctx, x, y);
if (hasStroke) {
nscolor rgb;
mSource->GetStrokePaint(&rgb);
float opacity;
mSource->GetStrokeOpacity(&opacity);
cairo_set_source_rgba(ctx,
NS_GET_R(rgb)/255.0,
NS_GET_G(rgb)/255.0,
NS_GET_B(rgb)/255.0,
opacity);
float width;
mSource->GetStrokeWidth(&width);
cairo_set_line_width(ctx, double(width));
PRUint16 capStyle;
mSource->GetStrokeLinecap(&capStyle);
switch (capStyle) {
case nsISVGGeometrySource::STROKE_LINECAP_BUTT:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_BUTT);
break;
case nsISVGGeometrySource::STROKE_LINECAP_ROUND:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
break;
case nsISVGGeometrySource::STROKE_LINECAP_SQUARE:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_SQUARE);
break;
}
float miterlimit;
mSource->GetStrokeMiterlimit(&miterlimit);
cairo_set_miter_limit(ctx, double(miterlimit));
PRUint16 joinStyle;
mSource->GetStrokeLinejoin(&joinStyle);
switch(joinStyle) {
case nsISVGGeometrySource::STROKE_LINEJOIN_MITER:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_MITER);
break;
case nsISVGGeometrySource::STROKE_LINEJOIN_ROUND:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND);
break;
case nsISVGGeometrySource::STROKE_LINEJOIN_BEVEL:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_BEVEL);
break;
}
float *dashArray, offset;
PRUint32 count;
mSource->GetStrokeDashArray(&dashArray, &count);
if (count > 0) {
double *dashes = new double[count];
for (unsigned i=0; i<count; i++)
dashes[i] = dashArray[i];
mSource->GetStrokeDashoffset(&offset);
cairo_set_dash(ctx, dashes, count, double(offset));
nsMemory::Free(dashArray);
delete [] dashes;
}
aSource->SetupCairoStroke(ctx);
LOOP_CHARS(cairo_text_path)
if (stroketype == nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR) {
if (stroketype == eStyleSVGPaintType_Color) {
cairo_stroke(ctx);
} else if (stroketype == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (strokeServerType == nsISVGGeometrySource::PAINT_TYPE_GRADIENT) {
} else if (stroketype == eStyleSVGPaintType_Server) {
if (strokeServerType == nsSVGGeometryFrame::PAINT_TYPE_GRADIENT) {
nsISVGGradient *aGrad;
mSource->GetStrokeGradient(&aGrad);
aSource->GetStrokeGradient(&aGrad);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, mSource);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, aSource);
if (gradient) {
cairo_set_source(ctx, gradient);
cairo_stroke(ctx);
cairo_pattern_destroy(gradient);
}
} else if (strokeServerType == nsISVGGeometrySource::PAINT_TYPE_PATTERN) {
} else if (strokeServerType == nsSVGGeometryFrame::PAINT_TYPE_PATTERN) {
nsISVGPattern *aPat;
mSource->GetStrokePattern(&aPat);
aSource->GetStrokePattern(&aPat);
// Paint the pattern -- note that because we will call back into the
// layout layer to paint, we need to pass the canvas, not just the context
nsISVGGeometrySource *aGsource;
CallQueryInterface(mSource, &aGsource);
nsCOMPtr<nsISVGRendererSurface> patSurface;
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, aGsource, getter_AddRefs(patSurface));
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, aSource, getter_AddRefs(patSurface));
if (pattern) {
cairo_set_source(ctx, pattern);
cairo_stroke(ctx);
@ -406,7 +318,9 @@ nsSVGCairoGlyphGeometry::Render(nsISVGRendererCanvas *canvas)
/** Implements nsISVGRendererRegion update(in unsigned long updatemask); */
NS_IMETHODIMP
nsSVGCairoGlyphGeometry::Update(PRUint32 updatemask, nsISVGRendererRegion **_retval)
nsSVGCairoGlyphGeometry::Update(nsSVGGlyphFrame *aSource,
PRUint32 updatemask,
nsISVGRendererRegion **_retval)
{
*_retval = nsnull;
@ -416,26 +330,26 @@ nsSVGCairoGlyphGeometry::Update(PRUint32 updatemask, nsISVGRendererRegion **_ret
nsISVGGlyphGeometrySource::UPDATEMASK_METRICS |
nsISVGGlyphGeometrySource::UPDATEMASK_X |
nsISVGGlyphGeometrySource::UPDATEMASK_Y |
nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT_TYPE |
nsISVGGeometrySource::UPDATEMASK_STROKE_WIDTH |
nsISVGGeometrySource::UPDATEMASK_STROKE_LINECAP |
nsISVGGeometrySource::UPDATEMASK_STROKE_LINEJOIN |
nsISVGGeometrySource::UPDATEMASK_STROKE_MITERLIMIT |
nsISVGGeometrySource::UPDATEMASK_STROKE_DASH_ARRAY |
nsISVGGeometrySource::UPDATEMASK_STROKE_DASHOFFSET |
nsISVGGeometrySource::UPDATEMASK_CANVAS_TM;
nsSVGGeometryFrame::UPDATEMASK_STROKE_PAINT_TYPE |
nsSVGGeometryFrame::UPDATEMASK_STROKE_WIDTH |
nsSVGGeometryFrame::UPDATEMASK_STROKE_LINECAP |
nsSVGGeometryFrame::UPDATEMASK_STROKE_LINEJOIN |
nsSVGGeometryFrame::UPDATEMASK_STROKE_MITERLIMIT |
nsSVGGeometryFrame::UPDATEMASK_STROKE_DASH_ARRAY |
nsSVGGeometryFrame::UPDATEMASK_STROKE_DASHOFFSET |
nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM;
const unsigned long regionsmask =
nsISVGGlyphGeometrySource::UPDATEMASK_METRICS |
nsISVGGlyphGeometrySource::UPDATEMASK_X |
nsISVGGlyphGeometrySource::UPDATEMASK_Y |
nsISVGGeometrySource::UPDATEMASK_CANVAS_TM;
nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM;
nsCOMPtr<nsISVGRendererRegion> before = mCoveredRegion;
if ((updatemask & regionsmask) || (updatemask & strokemask)) {
nsCOMPtr<nsISVGRendererRegion> after;
GetCoveredRegion(getter_AddRefs(after));
GetCoveredRegion(aSource, getter_AddRefs(after));
if (mCoveredRegion) {
if (after)
@ -457,7 +371,8 @@ nsSVGCairoGlyphGeometry::Update(PRUint32 updatemask, nsISVGRendererRegion **_ret
/** Implements nsISVGRendererRegion getCoveredRegion(); */
NS_IMETHODIMP
nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
nsSVGCairoGlyphGeometry::GetCoveredRegion(nsSVGGlyphFrame *aSource,
nsISVGRendererRegion **_retval)
{
*_retval = nsnull;
@ -467,14 +382,14 @@ nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
nsCOMPtr<nsISVGCairoGlyphMetrics> metrics;
{
nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;
mSource->GetMetrics(getter_AddRefs(xpmetrics));
aSource->GetMetrics(getter_AddRefs(xpmetrics));
metrics = do_QueryInterface(xpmetrics);
NS_ASSERTION(metrics, "wrong metrics object!");
if (!metrics)
return NS_ERROR_FAILURE;
}
if (NS_FAILED(GetGlobalTransform(ctx, nsnull))) {
if (NS_FAILED(GetGlobalTransform(aSource, ctx, nsnull))) {
cairo_destroy(ctx);
return NS_ERROR_FAILURE;
}
@ -483,30 +398,30 @@ nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp)))) {
if (NS_FAILED(aSource->GetCharacterPosition(getter_Transfers(cp)))) {
cairo_destroy(ctx);
return NS_ERROR_FAILURE;
}
float x,y;
if (!cp) {
mSource->GetX(&x);
mSource->GetY(&y);
aSource->GetX(&x);
aSource->GetY(&y);
cairo_move_to(ctx, x, y);
} else {
x = 0.0, y = 0.0;
}
PRUint16 type;
mSource->GetFillPaintType(&type);
PRBool hasCoveredFill = type != nsISVGGeometrySource::PAINT_TYPE_NONE;
mSource->GetStrokePaintType(&type);
bool hasCoveredStroke = type != nsISVGGeometrySource::PAINT_TYPE_NONE;
PRBool hasCoveredFill =
aSource->GetFillPaintType() != eStyleSVGPaintType_None;
bool hasCoveredStroke =
aSource->GetStrokePaintType() != eStyleSVGPaintType_None;
if (!hasCoveredFill && !hasCoveredStroke) return NS_OK;
nsAutoString text;
mSource->GetCharacterData(text);
aSource->GetCharacterData(text);
if (text.Length() == 0) {
double xx = x, yy = y;
@ -555,42 +470,7 @@ nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
double xmin, ymin, xmax, ymax;
if (hasCoveredStroke) {
float width;
mSource->GetStrokeWidth(&width);
cairo_set_line_width(ctx, double(width));
PRUint16 capStyle;
mSource->GetStrokeLinecap(&capStyle);
switch (capStyle) {
case nsISVGGeometrySource::STROKE_LINECAP_BUTT:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_BUTT);
break;
case nsISVGGeometrySource::STROKE_LINECAP_ROUND:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
break;
case nsISVGGeometrySource::STROKE_LINECAP_SQUARE:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_SQUARE);
break;
}
float miterlimit;
mSource->GetStrokeMiterlimit(&miterlimit);
cairo_set_miter_limit(ctx, double(miterlimit));
PRUint16 joinStyle;
mSource->GetStrokeLinejoin(&joinStyle);
switch(joinStyle) {
case nsISVGGeometrySource::STROKE_LINEJOIN_MITER:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_MITER);
break;
case nsISVGGeometrySource::STROKE_LINEJOIN_ROUND:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND);
break;
case nsISVGGeometrySource::STROKE_LINEJOIN_BEVEL:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_BEVEL);
break;
}
aSource->SetupCairoStrokeGeometry(ctx);
cairo_stroke_extents(ctx, &xmin, &ymin, &xmax, &ymax);
} else {
cairo_fill_extents(ctx, &xmin, &ymin, &xmax, &ymax);
@ -606,7 +486,8 @@ nsSVGCairoGlyphGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
/** Implements boolean containsPoint(in float x, in float y); */
NS_IMETHODIMP
nsSVGCairoGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
nsSVGCairoGlyphGeometry::ContainsPoint(nsSVGGlyphFrame *aSource,
float x, float y, PRBool *_retval)
{
*_retval = PR_FALSE;
@ -614,7 +495,7 @@ nsSVGCairoGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
nsCOMPtr<nsISVGCairoGlyphMetrics> metrics;
{
nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;
mSource->GetMetrics(getter_AddRefs(xpmetrics));
aSource->GetMetrics(getter_AddRefs(xpmetrics));
metrics = do_QueryInterface(xpmetrics);
NS_ASSERTION(metrics, "wrong metrics object!");
if (!metrics)
@ -622,7 +503,7 @@ nsSVGCairoGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
}
cairo_t *ctx = cairo_create(gSVGCairoDummySurface);
if (NS_FAILED(GetGlobalTransform(ctx, nsnull))) {
if (NS_FAILED(GetGlobalTransform(aSource, ctx, nsnull))) {
cairo_destroy(ctx);
return NS_ERROR_FAILURE;
}
@ -630,19 +511,19 @@ nsSVGCairoGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
metrics->SelectFont(ctx);
nsAutoString text;
mSource->GetCharacterData(text);
aSource->GetCharacterData(text);
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp)))) {
if (NS_FAILED(aSource->GetCharacterPosition(getter_Transfers(cp)))) {
cairo_destroy(ctx);
return NS_ERROR_FAILURE;
}
float xx, yy;
if (!cp) {
mSource->GetX(&xx);
mSource->GetY(&yy);
aSource->GetX(&xx);
aSource->GetY(&yy);
}
cairo_matrix_t matrix;
@ -688,10 +569,12 @@ nsSVGCairoGlyphGeometry::ContainsPoint(float x, float y, PRBool *_retval)
nsresult
nsSVGCairoGlyphGeometry::GetGlobalTransform(cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
nsSVGCairoGlyphGeometry::GetGlobalTransform(nsSVGGlyphFrame *aSource,
cairo_t *ctx,
nsISVGCairoCanvas* aCanvas)
{
nsCOMPtr<nsIDOMSVGMatrix> ctm;
mSource->GetCanvasTM(getter_AddRefs(ctm));
aSource->GetCanvasTM(getter_AddRefs(ctm));
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
float m[6];
@ -730,7 +613,8 @@ nsSVGCairoGlyphGeometry::GetGlobalTransform(cairo_t *ctx, nsISVGCairoCanvas* aCa
}
NS_IMETHODIMP
nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
nsSVGCairoGlyphGeometry::GetBoundingBox(nsSVGGlyphFrame *aSource,
nsIDOMSVGRect * *aBoundingBox)
{
*aBoundingBox = nsnull;
@ -739,20 +623,20 @@ nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
if (!rect) return NS_ERROR_FAILURE;
nsAutoString text;
mSource->GetCharacterData(text);
aSource->GetCharacterData(text);
if (!text.Length())
return NS_OK;
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
if (NS_FAILED(mSource->GetCharacterPosition(getter_Transfers(cp))))
if (NS_FAILED(aSource->GetCharacterPosition(getter_Transfers(cp))))
return NS_ERROR_FAILURE;
double xmin, ymin, xmax, ymax;
cairo_t *ctx = cairo_create(gSVGCairoDummySurface);
if (NS_FAILED(GetGlobalTransform(ctx, nsnull))) {
if (NS_FAILED(GetGlobalTransform(aSource, ctx, nsnull))) {
cairo_destroy(ctx);
return NS_ERROR_FAILURE;
}
@ -761,7 +645,7 @@ nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
nsCOMPtr<nsISVGCairoGlyphMetrics> metrics;
{
nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;
mSource->GetMetrics(getter_AddRefs(xpmetrics));
aSource->GetMetrics(getter_AddRefs(xpmetrics));
metrics = do_QueryInterface(xpmetrics);
NS_ASSERTION(metrics, "wrong metrics object!");
if (!metrics)
@ -772,8 +656,8 @@ nsSVGCairoGlyphGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
float x,y;
if (!cp) {
mSource->GetX(&x);
mSource->GetY(&y);
aSource->GetX(&x);
aSource->GetY(&y);
cairo_move_to(ctx, x, y);
}

Просмотреть файл

@ -1,52 +0,0 @@
/* -*- 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 Cairo Renderer project.
*
* The Initial Developer of the Original Code is IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Parts of this file contain code derived from the following files(s)
* of the Mozilla SVG project (these parts are Copyright (C) by their
* respective copyright-holders):
* layout/svg/renderer/src/gdiplus/nsSVGGDIPlusGlyphGeometry.h
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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_SVGCAIRO_GLYPHGEOMETRY_H__
#define __NS_SVGCAIRO_GLYPHGEOMETRY_H__
class nsISVGRendererGlyphGeometry;
class nsISVGGlyphGeometrySource;
nsresult
NS_NewSVGCairoGlyphGeometry(nsISVGRendererGlyphGeometry **result,
nsISVGGlyphGeometrySource *src);
#endif // __NS_SVGCAIRO_GLYPHGEOMETRY_H__

Просмотреть файл

@ -54,6 +54,7 @@
#include "nsIComponentManager.h"
#include "nsSVGUtils.h"
#include "nsDOMError.h"
#include "nsIFrame.h"
#include <cairo.h>
extern cairo_surface_t *gSVGCairoDummySurface;
@ -575,8 +576,10 @@ nsSVGCairoGlyphMetrics::SelectFont(cairo_t *ctx)
cairo_select_font_face(ctx, f, slant, weight);
nsMemory::Free(f);
nsCOMPtr<nsPresContext> presContext;
mSource->GetPresContext(getter_AddRefs(presContext));
nsIFrame *frame;
CallQueryInterface(mSource, &frame);
nsPresContext *presContext = frame->GetPresContext();
float pxPerTwips;
pxPerTwips = presContext->TwipsToPixels();
// Since SVG has its own scaling, we really don't want

Просмотреть файл

@ -46,7 +46,8 @@
#include "nsIDOMSVGGradientElement.h"
#include "nsISVGPathGeometrySource.h"
#include "nsSVGCairoGradient.h"
#include "nsSVGGeometryFrame.h"
#include "nsISVGGradient.h"
static cairo_matrix_t SVGToMatrix(nsIDOMSVGMatrix *ctm)
{
@ -151,7 +152,7 @@ CairoRadialGradient(cairo_t *ctx, nsISVGGradient *aGrad)
cairo_pattern_t *
CairoGradient(cairo_t *ctx, nsISVGGradient *aGrad,
nsISVGGeometrySource *aSource)
nsSVGGeometryFrame *aSource)
{
NS_ASSERTION(aGrad, "Called CairoGradient without a gradient!");
if (!aGrad)
@ -190,10 +191,7 @@ CairoGradient(cairo_t *ctx, nsISVGGradient *aGrad,
cairo_pattern_set_matrix(gradient, &patternMatrix);
float opacity;
aSource->GetFillOpacity(&opacity);
CairoSetStops(gradient, aGrad, opacity);
CairoSetStops(gradient, aGrad, aSource->GetFillOpacity());
return gradient;
}

Просмотреть файл

@ -42,12 +42,14 @@
#ifndef __NS_SVGCAIROGRADIENT_H__
#define __NS_SVGCAIROGRADIENT_H__
#include "nsISVGGradient.h"
#include "cairo.h"
class nsISVGGradient;
class nsSVGGeometryFrame;
cairo_pattern_t *
CairoGradient(cairo_t *ctx,
nsISVGGradient *aGrad,
nsISVGGeometrySource *aSource);
nsSVGGeometryFrame *aSource);
#endif

Просмотреть файл

@ -61,6 +61,7 @@
#include "nsSVGTypeCIDs.h"
#include "nsIComponentManager.h"
#include "nsISVGPathFlatten.h"
#include "nsSVGPathGeometryFrame.h"
#ifdef DEBUG
#include <stdio.h>
#endif
@ -78,11 +79,7 @@ extern cairo_surface_t *gSVGCairoDummySurface;
class nsSVGCairoPathGeometry : public nsISVGRendererPathGeometry
{
protected:
friend nsresult NS_NewSVGCairoPathGeometry(nsISVGRendererPathGeometry **result,
nsISVGPathGeometrySource *src);
nsSVGCairoPathGeometry(nsISVGPathGeometrySource* src);
~nsSVGCairoPathGeometry();
friend nsresult NS_NewSVGCairoPathGeometry(nsISVGRendererPathGeometry **result);
public:
// nsISupports interface:
@ -92,10 +89,10 @@ public:
NS_DECL_NSISVGRENDERERPATHGEOMETRY
private:
nsISVGPathGeometrySource *mSource;
nsCOMPtr<nsISVGRendererRegion> mCoveredRegion;
void GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas);
void GeneratePath(nsSVGPathGeometryFrame *aSource,
cairo_t *ctx, nsISVGCairoCanvas* aCanvas);
};
/** @} */
@ -104,20 +101,10 @@ private:
//----------------------------------------------------------------------
// implementation:
nsSVGCairoPathGeometry::nsSVGCairoPathGeometry(nsISVGPathGeometrySource* src)
: mSource(src)
{
}
nsSVGCairoPathGeometry::~nsSVGCairoPathGeometry()
{
}
nsresult
NS_NewSVGCairoPathGeometry(nsISVGRendererPathGeometry **result,
nsISVGPathGeometrySource *src)
NS_NewSVGCairoPathGeometry(nsISVGRendererPathGeometry **result)
{
*result = new nsSVGCairoPathGeometry(src);
*result = new nsSVGCairoPathGeometry;
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*result);
@ -138,10 +125,11 @@ NS_INTERFACE_MAP_END
//----------------------------------------------------------------------
void
nsSVGCairoPathGeometry::GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
nsSVGCairoPathGeometry::GeneratePath(nsSVGPathGeometryFrame *aSource,
cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
{
nsCOMPtr<nsIDOMSVGMatrix> ctm;
mSource->GetCanvasTM(getter_AddRefs(ctm));
aSource->GetCanvasTM(getter_AddRefs(ctm));
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
float m[6];
@ -178,71 +166,7 @@ nsSVGCairoPathGeometry::GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
cairo_set_matrix(ctx, &matrix);
cairo_new_path(ctx);
mSource->ConstructPath(ctx);
PRUint16 type;
mSource->GetStrokePaintType(&type);
if (type != nsISVGGeometrySource::PAINT_TYPE_NONE) {
float width;
mSource->GetStrokeWidth(&width);
cairo_set_line_width(ctx, double(width));
PRUint16 capStyle;
mSource->GetStrokeLinecap(&capStyle);
switch (capStyle) {
case nsISVGGeometrySource::STROKE_LINECAP_BUTT:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_BUTT);
break;
case nsISVGGeometrySource::STROKE_LINECAP_ROUND:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
break;
case nsISVGGeometrySource::STROKE_LINECAP_SQUARE:
cairo_set_line_cap(ctx, CAIRO_LINE_CAP_SQUARE);
break;
}
float miterlimit;
mSource->GetStrokeMiterlimit(&miterlimit);
cairo_set_miter_limit(ctx, double(miterlimit));
PRUint16 joinStyle;
mSource->GetStrokeLinejoin(&joinStyle);
switch(joinStyle) {
case nsISVGGeometrySource::STROKE_LINEJOIN_MITER:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_MITER);
break;
case nsISVGGeometrySource::STROKE_LINEJOIN_ROUND:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND);
break;
case nsISVGGeometrySource::STROKE_LINEJOIN_BEVEL:
cairo_set_line_join(ctx, CAIRO_LINE_JOIN_BEVEL);
break;
}
float *dashArray, offset;
PRUint32 count;
mSource->GetStrokeDashArray(&dashArray, &count);
if (count > 0) {
double *dashes = new double[count];
for (unsigned i=0; i<count; i++)
dashes[i] = dashArray[i];
mSource->GetStrokeDashoffset(&offset);
cairo_set_dash(ctx, dashes, count, double(offset));
nsMemory::Free(dashArray);
delete [] dashes;
}
}
mSource->GetFillPaintType(&type);
if (type != nsISVGGeometrySource::PAINT_TYPE_NONE) {
PRUint16 rule;
mSource->GetFillRule(&rule);
if (rule == nsISVGGeometrySource::FILL_RULE_EVENODD)
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_WINDING);
}
aSource->ConstructPath(ctx);
}
@ -251,7 +175,8 @@ nsSVGCairoPathGeometry::GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
/** Implements void render(in nsISVGRendererCanvas canvas); */
NS_IMETHODIMP
nsSVGCairoPathGeometry::Render(nsISVGRendererCanvas *canvas)
nsSVGCairoPathGeometry::Render(nsSVGPathGeometryFrame *aSource,
nsISVGRendererCanvas *canvas)
{
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(canvas);
NS_ASSERTION(cairoCanvas, "wrong svg render context for geometry!");
@ -267,15 +192,12 @@ nsSVGCairoPathGeometry::Render(nsISVGRendererCanvas *canvas)
/* save/pop the state so we don't screw up the xform */
cairo_save(ctx);
GeneratePath(ctx, cairoCanvas);
GeneratePath(aSource, ctx, cairoCanvas);
if (renderMode != nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL) {
cairo_restore(ctx);
PRUint16 rule;
mSource->GetClipRule(&rule);
if (rule == nsISVGGeometrySource::FILL_RULE_EVENODD)
if (aSource->GetClipRule() == NS_STYLE_FILL_RULE_EVENODD)
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_WINDING);
@ -290,7 +212,7 @@ nsSVGCairoPathGeometry::Render(nsISVGRendererCanvas *canvas)
}
PRUint16 shapeMode;
mSource->GetShapeRendering(&shapeMode);
aSource->GetShapeRendering(&shapeMode);
switch (shapeMode) {
case nsISVGPathGeometrySource::SHAPE_RENDERING_OPTIMIZESPEED:
case nsISVGPathGeometrySource::SHAPE_RENDERING_CRISPEDGES:
@ -301,60 +223,50 @@ nsSVGCairoPathGeometry::Render(nsISVGRendererCanvas *canvas)
break;
}
PRUint16 strokeType, fillType;
PRUint16 strokeType = aSource->GetStrokePaintType();
PRUint16 fillType = aSource->GetFillPaintType();
PRUint16 strokeServerType = 0;
PRBool bStroking = PR_FALSE;
mSource->GetStrokePaintType(&strokeType);
if (strokeType != nsISVGGeometrySource::PAINT_TYPE_NONE) {
if (strokeType != eStyleSVGPaintType_None) {
bStroking = PR_TRUE;
if (strokeType == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (NS_FAILED(mSource->GetStrokePaintServerType(&strokeServerType)))
if (strokeType == eStyleSVGPaintType_Server) {
if (NS_FAILED(aSource->GetStrokePaintServerType(&strokeServerType)))
// unknown type or missing frame
bStroking = PR_FALSE;
}
}
mSource->GetFillPaintType(&fillType);
PRUint16 fillServerType = 0;
if (fillType == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (NS_FAILED(mSource->GetFillPaintServerType(&fillServerType)))
if (fillType == eStyleSVGPaintType_Server) {
if (NS_FAILED(aSource->GetFillPaintServerType(&fillServerType)))
// unknown type or missing frame
fillType = nsISVGGeometrySource::PAINT_TYPE_NONE;
fillType = eStyleSVGPaintType_None;
}
if (fillType != nsISVGGeometrySource::PAINT_TYPE_NONE) {
nscolor rgb;
mSource->GetFillPaint(&rgb);
float opacity;
mSource->GetFillOpacity(&opacity);
if (fillType != eStyleSVGPaintType_None) {
aSource->SetupCairoFill(ctx);
cairo_set_source_rgba(ctx,
NS_GET_R(rgb)/255.0,
NS_GET_G(rgb)/255.0,
NS_GET_B(rgb)/255.0,
opacity);
if (fillType == nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR) {
if (fillType == eStyleSVGPaintType_Color) {
cairo_fill_preserve(ctx);
} else if (fillType == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (fillServerType == nsISVGGeometrySource::PAINT_TYPE_GRADIENT) {
} else if (fillType == eStyleSVGPaintType_Server) {
if (fillServerType == nsSVGGeometryFrame::PAINT_TYPE_GRADIENT) {
nsISVGGradient *aGrad;
mSource->GetFillGradient(&aGrad);
aSource->GetFillGradient(&aGrad);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, mSource);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, aSource);
if (gradient) {
cairo_set_source(ctx, gradient);
cairo_fill_preserve(ctx);
cairo_pattern_destroy(gradient);
}
} else if (fillServerType == nsISVGGeometrySource::PAINT_TYPE_PATTERN) {
} else if (fillServerType == nsSVGGeometryFrame::PAINT_TYPE_PATTERN) {
nsISVGPattern *aPat;
mSource->GetFillPattern(&aPat);
aSource->GetFillPattern(&aPat);
// Paint the pattern -- note that because we will call back into the
// layout layer to paint, we need to pass the canvas, not just the context
nsCOMPtr<nsISVGRendererSurface> patSurface;
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, mSource, getter_AddRefs(patSurface));
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, aSource, getter_AddRefs(patSurface));
if (pattern) {
cairo_set_source(ctx, pattern);
cairo_fill_preserve(ctx);
@ -370,36 +282,28 @@ nsSVGCairoPathGeometry::Render(nsISVGRendererCanvas *canvas)
}
if (bStroking) {
nscolor rgb;
mSource->GetStrokePaint(&rgb);
float opacity;
mSource->GetStrokeOpacity(&opacity);
cairo_set_source_rgba(ctx,
NS_GET_R(rgb)/255.0,
NS_GET_G(rgb)/255.0,
NS_GET_B(rgb)/255.0,
opacity);
aSource->SetupCairoStroke(ctx);
if (strokeType == nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR) {
if (strokeType == eStyleSVGPaintType_Color) {
cairo_stroke(ctx);
} else if (strokeType == nsISVGGeometrySource::PAINT_TYPE_SERVER) {
if (strokeServerType == nsISVGGeometrySource::PAINT_TYPE_GRADIENT) {
} else if (strokeType == eStyleSVGPaintType_Server) {
if (strokeServerType == nsSVGGeometryFrame::PAINT_TYPE_GRADIENT) {
nsISVGGradient *aGrad;
mSource->GetStrokeGradient(&aGrad);
aSource->GetStrokeGradient(&aGrad);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, mSource);
cairo_pattern_t *gradient = CairoGradient(ctx, aGrad, aSource);
if (gradient) {
cairo_set_source(ctx, gradient);
cairo_stroke(ctx);
cairo_pattern_destroy(gradient);
}
} else if (strokeServerType == nsISVGGeometrySource::PAINT_TYPE_PATTERN) {
} else if (strokeServerType == nsSVGGeometryFrame::PAINT_TYPE_PATTERN) {
nsISVGPattern *aPat;
mSource->GetStrokePattern(&aPat);
aSource->GetStrokePattern(&aPat);
// Paint the pattern -- note that because we will call back into the
// layout layer to paint, we need to pass the canvas, not just the context
nsCOMPtr<nsISVGRendererSurface> patSurface;
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, mSource, getter_AddRefs(patSurface));
cairo_pattern_t *pattern = CairoPattern(canvas, aPat, aSource, getter_AddRefs(patSurface));
if (pattern) {
cairo_set_source(ctx, pattern);
cairo_stroke(ctx);
@ -418,38 +322,40 @@ nsSVGCairoPathGeometry::Render(nsISVGRendererCanvas *canvas)
/** Implements nsISVGRendererRegion update(in unsigned long updatemask); */
NS_IMETHODIMP
nsSVGCairoPathGeometry::Update(PRUint32 updatemask, nsISVGRendererRegion **_retval)
nsSVGCairoPathGeometry::Update(nsSVGPathGeometryFrame *aSource,
PRUint32 updatemask,
nsISVGRendererRegion **_retval)
{
*_retval = nsnull;
const unsigned long pathmask =
nsISVGPathGeometrySource::UPDATEMASK_PATH |
nsISVGGeometrySource::UPDATEMASK_CANVAS_TM;
nsSVGGeometryFrame::UPDATEMASK_CANVAS_TM;
const unsigned long fillmask =
pathmask |
nsISVGGeometrySource::UPDATEMASK_FILL_RULE;
nsSVGGeometryFrame::UPDATEMASK_FILL_RULE;
const unsigned long strokemask =
pathmask |
nsISVGGeometrySource::UPDATEMASK_STROKE_WIDTH |
nsISVGGeometrySource::UPDATEMASK_STROKE_LINECAP |
nsISVGGeometrySource::UPDATEMASK_STROKE_LINEJOIN |
nsISVGGeometrySource::UPDATEMASK_STROKE_MITERLIMIT |
nsISVGGeometrySource::UPDATEMASK_STROKE_DASH_ARRAY |
nsISVGGeometrySource::UPDATEMASK_STROKE_DASHOFFSET;
nsSVGGeometryFrame::UPDATEMASK_STROKE_WIDTH |
nsSVGGeometryFrame::UPDATEMASK_STROKE_LINECAP |
nsSVGGeometryFrame::UPDATEMASK_STROKE_LINEJOIN |
nsSVGGeometryFrame::UPDATEMASK_STROKE_MITERLIMIT |
nsSVGGeometryFrame::UPDATEMASK_STROKE_DASH_ARRAY |
nsSVGGeometryFrame::UPDATEMASK_STROKE_DASHOFFSET;
const unsigned long coveredregionmask =
fillmask |
strokemask |
nsISVGGeometrySource::UPDATEMASK_FILL_PAINT_TYPE |
nsISVGGeometrySource::UPDATEMASK_STROKE_PAINT_TYPE;
fillmask |
strokemask |
nsSVGGeometryFrame::UPDATEMASK_FILL_PAINT_TYPE |
nsSVGGeometryFrame::UPDATEMASK_STROKE_PAINT_TYPE;
nsCOMPtr<nsISVGRendererRegion> before = mCoveredRegion;
if (updatemask & coveredregionmask) {
nsCOMPtr<nsISVGRendererRegion> after;
GetCoveredRegion(getter_AddRefs(after));
GetCoveredRegion(aSource, getter_AddRefs(after));
if (mCoveredRegion) {
if (after)
@ -471,28 +377,29 @@ nsSVGCairoPathGeometry::Update(PRUint32 updatemask, nsISVGRendererRegion **_retv
/** Implements nsISVGRendererRegion getCoveredRegion(); */
NS_IMETHODIMP
nsSVGCairoPathGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
nsSVGCairoPathGeometry::GetCoveredRegion(nsSVGPathGeometryFrame *aSource,
nsISVGRendererRegion **_retval)
{
*_retval = nsnull;
cairo_t *ctx = cairo_create(gSVGCairoDummySurface);
GeneratePath(ctx, nsnull);
GeneratePath(aSource, ctx, nsnull);
PRUint16 type;
mSource->GetFillPaintType(&type);
PRBool hasCoveredFill = type != nsISVGGeometrySource::PAINT_TYPE_NONE;
PRBool hasCoveredFill =
aSource->GetFillPaintType() != eStyleSVGPaintType_None;
mSource->GetStrokePaintType(&type);
bool hasCoveredStroke = type != nsISVGGeometrySource::PAINT_TYPE_NONE;
bool hasCoveredStroke =
aSource->GetStrokePaintType() != eStyleSVGPaintType_None;
if (!hasCoveredFill && !hasCoveredStroke) return NS_OK;
double xmin, ymin, xmax, ymax;
if (hasCoveredStroke)
if (hasCoveredStroke) {
aSource->SetupCairoStrokeGeometry(ctx);
cairo_stroke_extents(ctx, &xmin, &ymin, &xmax, &ymax);
else
} else
cairo_fill_extents(ctx, &xmin, &ymin, &xmax, &ymax);
cairo_user_to_device(ctx, &xmin, &ymin);
@ -505,7 +412,8 @@ nsSVGCairoPathGeometry::GetCoveredRegion(nsISVGRendererRegion **_retval)
/** Implements boolean containsPoint(in float x, in float y); */
NS_IMETHODIMP
nsSVGCairoPathGeometry::ContainsPoint(float x, float y, PRBool *_retval)
nsSVGCairoPathGeometry::ContainsPoint(nsSVGPathGeometryFrame *aSource,
float x, float y, PRBool *_retval)
{
*_retval = PR_FALSE;
@ -519,23 +427,19 @@ nsSVGCairoPathGeometry::ContainsPoint(float x, float y, PRBool *_retval)
cairo_t *ctx = cairo_create(gSVGCairoDummySurface);
cairo_set_tolerance(ctx, 1.0);
GeneratePath(ctx, nsnull);
GeneratePath(aSource, ctx, nsnull);
double xx = x, yy = y;
cairo_device_to_user(ctx, &xx, &yy);
PRBool isClip;
mSource->IsClipChild(&isClip);
if (isClip) {
PRUint16 rule;
mSource->GetClipRule(&rule);
if (rule == nsISVGGeometrySource::FILL_RULE_EVENODD)
if (aSource->IsClipChild()) {
if (aSource->GetClipRule() == NS_STYLE_FILL_RULE_EVENODD)
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_WINDING);
}
PRUint16 mask = 0;
mSource->GetHittestMask(&mask);
aSource->GetHittestMask(&mask);
if (mask & nsISVGPathGeometrySource::HITTEST_MASK_FILL)
*_retval = cairo_in_fill(ctx, xx, yy);
if (!*_retval && (mask & nsISVGPathGeometrySource::HITTEST_MASK_STROKE))
@ -547,7 +451,8 @@ nsSVGCairoPathGeometry::ContainsPoint(float x, float y, PRBool *_retval)
}
NS_IMETHODIMP
nsSVGCairoPathGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
nsSVGCairoPathGeometry::GetBoundingBox(nsSVGPathGeometryFrame *aSource,
nsIDOMSVGRect * *aBoundingBox)
{
*aBoundingBox = nsnull;
@ -559,7 +464,7 @@ nsSVGCairoPathGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
double xmin, ymin, xmax, ymax;
cairo_t *ctx = cairo_create(gSVGCairoDummySurface);
GeneratePath(ctx, nsnull);
GeneratePath(aSource, ctx, nsnull);
cairo_fill_extents(ctx, &xmin, &ymin, &xmax, &ymax);
#ifdef DEBUG_scooter
@ -593,10 +498,11 @@ nsSVGCairoPathGeometry::GetBoundingBox(nsIDOMSVGRect * *aBoundingBox)
}
NS_IMETHODIMP
nsSVGCairoPathGeometry::Flatten(nsSVGPathData **aData)
nsSVGCairoPathGeometry::Flatten(nsSVGPathGeometryFrame *aSource,
nsSVGPathData **aData)
{
cairo_t *ctx = cairo_create(gSVGCairoDummySurface);
GeneratePath(ctx, nsnull);
GeneratePath(aSource, ctx, nsnull);
*aData = new nsSVGPathData;

Просмотреть файл

@ -1,52 +0,0 @@
/* -*- 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 Cairo Renderer project.
*
* The Initial Developer of the Original Code is IBM Corporation.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Parts of this file contain code derived from the following files(s)
* of the Mozilla SVG project (these parts are Copyright (C) by their
* respective copyright-holders):
* layout/svg/renderer/src/libart/nsSVGLibartPathGeometry.h
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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_SVGCAIRO_PATHGEOMETRY_H__
#define __NS_SVGCAIRO_PATHGEOMETRY_H__
class nsISVGRendererPathGeometry;
class nsISVGPathGeometrySource;
nsresult
NS_NewSVGCairoPathGeometry(nsISVGRendererPathGeometry **result,
nsISVGPathGeometrySource *src);
#endif // __NS_SVGCAIRO_PATHGEOMETRY_H__

Просмотреть файл

@ -52,6 +52,8 @@
#include "nsSVGCairoCanvas.h"
#include "nsSVGCairoSurface.h"
#include "nsSVGCairoPattern.h"
#include "nsISVGPattern.h"
#include "nsSVGGeometryFrame.h"
#ifdef DEBUG
#include <stdio.h>
@ -77,7 +79,7 @@ void dumpPattern(nsISVGCairoSurface *surf);
cairo_pattern_t *
CairoPattern(nsISVGRendererCanvas *canvas, nsISVGPattern *aPat,
nsISVGGeometrySource *aSource, nsISVGRendererSurface **aSurface)
nsSVGGeometryFrame *aSource, nsISVGRendererSurface **aSurface)
{
*aSurface = nsnull;
NS_ASSERTION(aPat, "Called CairoPattern without a pattern!");

Просмотреть файл

@ -44,14 +44,17 @@
#ifndef __NS_SVGCAIROPATTERN_H__
#define __NS_SVGCAIROPATTERN_H__
#include "nsISVGPattern.h"
#include "nsISVGRendererCanvas.h"
#include "cairo.h"
class nsISVGRendererCanvas;
class nsISVGPattern;
class nsSVGGeometryFrame;
class nsISVGRendererSurface;
cairo_pattern_t *
CairoPattern(nsISVGRendererCanvas *canvas,
nsISVGPattern *aPat,
nsISVGGeometrySource *aSource,
nsSVGGeometryFrame *aSource,
nsISVGRendererSurface **aSurface);
#endif

Просмотреть файл

@ -112,12 +112,11 @@ NS_IMPL_ISUPPORTS1(nsSVGRendererCairo, nsISVGRenderer)
//----------------------------------------------------------------------
// nsISVGRenderer methods
/** Implements nsISVGRendererPathGeometry createPathGeometry(in nsISVGPathGeometrySource src); */
/** Implements nsISVGRendererPathGeometry createPathGeometry(); */
NS_IMETHODIMP
nsSVGRendererCairo::CreatePathGeometry(nsISVGPathGeometrySource *src,
nsISVGRendererPathGeometry **_retval)
nsSVGRendererCairo::CreatePathGeometry(nsISVGRendererPathGeometry **_retval)
{
return NS_NewSVGCairoPathGeometry(_retval, src);
return NS_NewSVGCairoPathGeometry(_retval);
}
/** Implements nsISVGRendererGlyphMetrics createGlyphMetrics(in nsISVGGlyphMetricsSource src); */
@ -130,10 +129,9 @@ nsSVGRendererCairo::CreateGlyphMetrics(nsISVGGlyphMetricsSource *src,
/** Implements nsISVGRendererGlyphGeometry createGlyphGeometry(in nsISVGGlyphGeometrySource src); */
NS_IMETHODIMP
nsSVGRendererCairo::CreateGlyphGeometry(nsISVGGlyphGeometrySource *src,
nsISVGRendererGlyphGeometry **_retval)
nsSVGRendererCairo::CreateGlyphGeometry(nsISVGRendererGlyphGeometry **_retval)
{
return NS_NewSVGCairoGlyphGeometry(_retval, src);
return NS_NewSVGCairoGlyphGeometry(_retval);
}
/** Implements [noscript] nsISVGRendererCanvas createCanvas(in nsIRenderingContext ctx,