Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsSVGCairoSurface.cpp File Reference
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsSVGCairoSurface.h"
#include "nsISVGCairoSurface.h"
#include "prmem.h"
#include "cairo.h"

Go to the source code of this file.


class  nsSVGCairoSurface
 Cairo surface implementation. More...


static PRBool CheckSaneImageSize (PRUint32 width, PRUint32 height)
nsresult NS_NewSVGCairoSurface (nsISVGRendererSurface **result, PRUint32 width, PRUint32 height)

Function Documentation

static PRBool CheckSaneImageSize ( PRUint32  width,
PRUint32  height 
) [static]

Definition at line 97 of file nsSVGCairoSurface.cpp.

    if (width <= 0 || height <= 0)
        return PR_FALSE;

    /* check to make sure we don't overflow a 32-bit */
    PRUint32 tmp = width * height;
    if (tmp / height != width)
        return PR_FALSE;

    tmp = tmp * 4;
    if (tmp / 4 != width * height)
        return PR_FALSE;

    /* reject over-wide or over-tall images */
    const PRUint32 k64KLimit = 0x0000FFFF;
    if (width > k64KLimit || height > k64KLimit)
        return PR_FALSE;

    return PR_TRUE;

Here is the caller graph for this function:

Definition at line 143 of file nsSVGCairoSurface.cpp.

  nsSVGCairoSurface* surf = new nsSVGCairoSurface();
  if (!surf)


  nsresult rv = surf->Init(width, height);

  if (NS_FAILED(rv)) {
    return rv;
  *result = surf;
  return rv;

Here is the call graph for this function: