зеркало из https://github.com/mozilla/pjs.git
Bug 350059 Allow cairo.h usage in nsSVGUtils.h. r+sr=roc
This commit is contained in:
Родитель
f96d1fa6ac
Коммит
18d12280d2
|
@ -57,7 +57,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
|||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsSVGUtils.h"
|
||||
PRBool NS_SVGEnabled();
|
||||
#endif
|
||||
|
||||
#define kXMLNSNameSpaceURI "http://www.w3.org/2000/xmlns/"
|
||||
|
@ -253,8 +253,7 @@ NS_NewElement(nsIContent** aResult, PRInt32 aElementType,
|
|||
}
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
if (aElementType == kNameSpaceID_SVG &&
|
||||
nsSVGUtils::SVGEnabled()) {
|
||||
if (aElementType == kNameSpaceID_SVG && NS_SVGEnabled()) {
|
||||
return NS_NewSVGElement(aResult, aNodeInfo);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -132,7 +132,7 @@ NS_NewSVGMaskElement(nsIContent **aResult, nsINodeInfo *aNodeInfo);
|
|||
nsresult
|
||||
NS_NewSVGElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
|
||||
{
|
||||
NS_PRECONDITION(nsSVGUtils::SVGEnabled(),
|
||||
NS_PRECONDITION(NS_SVGEnabled(),
|
||||
"creating an SVG element while SVG disabled");
|
||||
|
||||
static const char kSVGStyleSheetURI[] = "resource://gre/res/svg.css";
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
// Test to see if a feature is implemented
|
||||
PRBool
|
||||
NS_SVG_TestFeature(const nsAString& fstr) {
|
||||
if (!nsSVGUtils::SVGEnabled()) {
|
||||
if (!NS_SVGEnabled()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsAutoString lstr(fstr);
|
||||
|
|
|
@ -320,17 +320,3 @@ nsSVGMatrix::GetValueString(nsAString& aValue)
|
|||
NS_NOTYETIMPLEMENTED("nsSVGMatrix::GetValueString");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
cairo_matrix_t
|
||||
NS_ConvertSVGMatrixToCairo(nsIDOMSVGMatrix *aMatrix)
|
||||
{
|
||||
float A, B, C, D, E, F;
|
||||
aMatrix->GetA(&A);
|
||||
aMatrix->GetB(&B);
|
||||
aMatrix->GetC(&C);
|
||||
aMatrix->GetD(&D);
|
||||
aMatrix->GetE(&E);
|
||||
aMatrix->GetF(&F);
|
||||
cairo_matrix_t m = { A, B, C, D, E, F };
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -48,13 +48,4 @@ NS_NewSVGMatrix(nsIDOMSVGMatrix** result,
|
|||
float c = 0.0f, float d = 1.0f,
|
||||
float e = 0.0f, float f = 0.0f);
|
||||
|
||||
/*
|
||||
* Helper to convert a nsIDOMSVGMatrix to a cairo_matrix_t. Defined
|
||||
* here instead of in nsSVGUtils.h because that file is needed in
|
||||
* several places where it would be inappropriate to include cairo.h.
|
||||
*/
|
||||
|
||||
cairo_matrix_t
|
||||
NS_ConvertSVGMatrixToCairo(nsIDOMSVGMatrix *aMatrix);
|
||||
|
||||
#endif //__NS_SVGMATRIX_H__
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "nsISVGValueUtils.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGPoint.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
|
||||
nsSVGElement::NumberInfo nsSVGPathElement::sNumberInfo =
|
||||
{ &nsGkAtoms::pathLength, 0 };
|
||||
|
@ -456,7 +455,7 @@ nsSVGPathElement::GetFlattenedPath(nsIDOMSVGMatrix *aMatrix)
|
|||
}
|
||||
|
||||
if (aMatrix) {
|
||||
cairo_matrix_t matrix = NS_ConvertSVGMatrixToCairo(aMatrix);
|
||||
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(aMatrix);
|
||||
cairo_set_matrix(ctx, &matrix);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,8 +173,9 @@ NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|||
#include "nsSVGAtoms.h"
|
||||
#include "nsISVGTextContentMetrics.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsSVGUtils.h"
|
||||
|
||||
PRBool
|
||||
NS_SVGEnabled();
|
||||
nsIFrame*
|
||||
NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext);
|
||||
nsIFrame*
|
||||
|
@ -3522,8 +3523,7 @@ IsSpecialContent(nsIContent* aContent,
|
|||
PR_FALSE;
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (aNameSpaceID == kNameSpaceID_SVG &&
|
||||
nsSVGUtils::SVGEnabled()) {
|
||||
if (aNameSpaceID == kNameSpaceID_SVG && NS_SVGEnabled()) {
|
||||
// All SVG content is special...
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -4616,8 +4616,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState,
|
|||
else
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
if (aDocElement->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
nsSVGUtils::SVGEnabled()) {
|
||||
if (aDocElement->GetNameSpaceID() == kNameSpaceID_SVG && NS_SVGEnabled()) {
|
||||
contentFrame = NS_NewSVGOuterSVGFrame(mPresShell, aDocElement, styleContext);
|
||||
}
|
||||
else
|
||||
|
@ -8138,7 +8137,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsFrameConstructorState& aState,
|
|||
if (NS_SUCCEEDED(rv) &&
|
||||
(!frameItems->childList || lastChild == frameItems->lastChild) &&
|
||||
aNameSpaceID == kNameSpaceID_SVG &&
|
||||
nsSVGUtils::SVGEnabled()) {
|
||||
NS_SVGEnabled()) {
|
||||
PRBool haltProcessing;
|
||||
rv = ConstructSVGFrame(aState, aContent, adjParentFrame, aTag,
|
||||
aNameSpaceID, styleContext,
|
||||
|
|
|
@ -113,7 +113,7 @@ static const char* const gSVGTypes[] = {
|
|||
0
|
||||
};
|
||||
|
||||
#include "nsSVGUtils.h"
|
||||
PRBool NS_SVGEnabled();
|
||||
#endif
|
||||
|
||||
static const char* const gRDFTypes[] = {
|
||||
|
@ -193,7 +193,7 @@ nsContentDLF::CreateInstance(const char* aCommand,
|
|||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (nsSVGUtils::SVGEnabled()) {
|
||||
if (NS_SVGEnabled()) {
|
||||
for (typeIndex = 0; gSVGTypes[typeIndex] && !knownType; ++typeIndex) {
|
||||
if (type.Equals(gSVGTypes[typeIndex])) {
|
||||
knownType = PR_TRUE;
|
||||
|
@ -241,7 +241,7 @@ nsContentDLF::CreateInstance(const char* aCommand,
|
|||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (nsSVGUtils::SVGEnabled()) {
|
||||
if (NS_SVGEnabled()) {
|
||||
// Try SVG
|
||||
typeIndex = 0;
|
||||
while(gSVGTypes[typeIndex]) {
|
||||
|
|
|
@ -90,7 +90,8 @@
|
|||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsSVGUtils.h"
|
||||
|
||||
PRBool NS_SVGEnabled();
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_NO_INSPECTOR_APIS
|
||||
|
@ -159,7 +160,7 @@ nsLayoutStatics::Initialize()
|
|||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (nsSVGUtils::SVGEnabled())
|
||||
if (NS_SVGEnabled())
|
||||
nsContentDLF::RegisterSVG();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "nsSVGPoint.h"
|
||||
#include "nsSVGRect.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsISVGCairoCanvas.h"
|
||||
#include "cairo.h"
|
||||
|
||||
|
@ -1486,7 +1485,7 @@ nsSVGGlyphFrame::GetGlobalTransform(cairo_t *ctx,
|
|||
GetCanvasTM(getter_AddRefs(ctm));
|
||||
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
|
||||
|
||||
cairo_matrix_t matrix = NS_ConvertSVGMatrixToCairo(ctm);
|
||||
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(ctm);
|
||||
if (aCanvas) {
|
||||
aCanvas->AdjustMatrixForInitialTransform(&matrix);
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ nsSVGGradientFrame::SetupPaintServer(nsISVGRendererCanvas *aCanvas,
|
|||
if (!svgMatrix)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
cairo_matrix_t patternMatrix = NS_ConvertSVGMatrixToCairo(svgMatrix);
|
||||
cairo_matrix_t patternMatrix = nsSVGUtils::ConvertSVGMatrixToCairo(svgMatrix);
|
||||
if (cairo_matrix_invert(&patternMatrix))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(canvas);
|
||||
cairo_matrix_t matrix = NS_ConvertSVGMatrixToCairo(fini);
|
||||
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(fini);
|
||||
cairoCanvas->AdjustMatrixForInitialTransform(&matrix);
|
||||
cairo_t *ctx = cairoCanvas->GetContext();
|
||||
|
||||
|
|
|
@ -645,7 +645,7 @@ nsSVGPathGeometryFrame::GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
|
|||
GetCanvasTM(getter_AddRefs(ctm));
|
||||
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
|
||||
|
||||
cairo_matrix_t matrix = NS_ConvertSVGMatrixToCairo(ctm);
|
||||
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(ctm);
|
||||
if (aCanvas) {
|
||||
aCanvas->AdjustMatrixForInitialTransform(&matrix);
|
||||
}
|
||||
|
|
|
@ -838,7 +838,7 @@ nsSVGPatternFrame::SetupPaintServer(nsISVGRendererCanvas *aCanvas,
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Translate the pattern frame
|
||||
cairo_matrix_t pmatrix = NS_ConvertSVGMatrixToCairo(pMatrix);
|
||||
cairo_matrix_t pmatrix = nsSVGUtils::ConvertSVGMatrixToCairo(pMatrix);
|
||||
cairoCanvas->AdjustMatrixForInitialTransform(&pmatrix);
|
||||
if (cairo_matrix_invert(&pmatrix))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -110,7 +110,7 @@ SVGPrefChanged(const char *aPref, void *aClosure)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsSVGUtils::SVGEnabled()
|
||||
NS_SVGEnabled()
|
||||
{
|
||||
static PRBool sInitialized = PR_FALSE;
|
||||
|
||||
|
@ -952,3 +952,17 @@ nsSVGUtils::GetCairoComputationalSurface()
|
|||
|
||||
return mCairoComputationalSurface;
|
||||
}
|
||||
|
||||
cairo_matrix_t
|
||||
nsSVGUtils::ConvertSVGMatrixToCairo(nsIDOMSVGMatrix *aMatrix)
|
||||
{
|
||||
float A, B, C, D, E, F;
|
||||
aMatrix->GetA(&A);
|
||||
aMatrix->GetB(&B);
|
||||
aMatrix->GetC(&C);
|
||||
aMatrix->GetD(&D);
|
||||
aMatrix->GetE(&E);
|
||||
aMatrix->GetF(&F);
|
||||
cairo_matrix_t m = { A, B, C, D, E, F };
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsISVGValue.h"
|
||||
#include "nsRect.h"
|
||||
#include "cairo.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsPresContext;
|
||||
|
@ -69,8 +70,6 @@ class nsSVGElement;
|
|||
class nsSVGCoordCtxProvider;
|
||||
class nsAttrValue;
|
||||
|
||||
typedef struct _cairo_surface cairo_surface_t;
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
@ -96,14 +95,17 @@ typedef struct _cairo_surface cairo_surface_t;
|
|||
/* are we the child of a non-display container? */
|
||||
#define NS_STATE_SVG_NONDISPLAY_CHILD 0x20000000
|
||||
|
||||
/*
|
||||
* Checks the svg enable preference and if a renderer could
|
||||
* successfully be created. Declared as a function instead of a
|
||||
* nsSVGUtil method so that files that can't pull in nsSVGUtils.h (due
|
||||
* to cairo.h usage) can still query this information.
|
||||
*/
|
||||
PRBool NS_SVGEnabled();
|
||||
|
||||
class nsSVGUtils
|
||||
{
|
||||
public:
|
||||
/* Checks the svg enable preference and if a renderer could
|
||||
* successfully be created.
|
||||
*/
|
||||
static PRBool SVGEnabled();
|
||||
|
||||
/*
|
||||
* Report a localized error message to the error console.
|
||||
*/
|
||||
|
@ -252,6 +254,12 @@ public:
|
|||
static cairo_surface_t *
|
||||
GetCairoComputationalSurface();
|
||||
|
||||
/*
|
||||
* Convert a nsIDOMSVGMatrix to a cairo_matrix_t.
|
||||
*/
|
||||
static cairo_matrix_t
|
||||
ConvertSVGMatrixToCairo(nsIDOMSVGMatrix *aMatrix);
|
||||
|
||||
private:
|
||||
/* Cairo computational (nil) surface */
|
||||
static cairo_surface_t *mCairoComputationalSurface;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "nsRect.h"
|
||||
#include "nsISVGCairoSurface.h"
|
||||
#include <cairo.h>
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGUtils.h"
|
||||
|
||||
#ifdef MOZ_X11
|
||||
extern "C" {
|
||||
|
@ -454,7 +454,7 @@ NS_INTERFACE_MAP_END
|
|||
|
||||
void nsSVGCairoCanvas::SetupCairoMatrix(nsIDOMSVGMatrix *aCTM)
|
||||
{
|
||||
cairo_matrix_t matrix = NS_ConvertSVGMatrixToCairo(aCTM);
|
||||
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(aCTM);
|
||||
AdjustMatrixForInitialTransform(&matrix);
|
||||
cairo_set_matrix(mCR, &matrix);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче