** nsCanvasRenderingContext2D
** nsCanvasPattern
NS_INTERFACE_MAP_END/** ** nsCanvasRenderingContext2D **/class nsCanvasRenderingContext2D :    public nsIDOMCanvasRenderingContext2D,    public nsICanvasRenderingContextInternal{public:    nsCanvasRenderingContext2D();    virtual ~nsCanvasRenderingContext2D();    nsresult Redraw();    void SetCairoColor(nscolor c);    // nsICanvasRenderingContextInternal    NS_IMETHOD SetCanvasElement(nsICanvasElement* aParentCanvas);    NS_IMETHOD SetTargetImageFrame(gfxIImageFrame* aImageFrame);    NS_IMETHOD GetInputStream(const nsACString& aMimeType,                              const nsAString& aEncoderOptions,                              nsIInputStream **aStream);    NS_IMETHOD UpdateImageFrame();    // nsISupports interface    NS_DECL_ISUPPORTS    // nsIDOMCanvasRenderingContext2D interface    NS_DECL_NSIDOMCANVASRENDERINGCONTEXT2Dprotected:    // destroy cairo/image stuff, in preparation for possibly recreating    void Destroy();    nsIFrame *GetCanvasLayoutFrame();    // Some helpers.  Doesn't modify acolor on failure.    enum {        STYLE_STROKE = 0,        STYLE_FILL,        STYLE_SHADOW,        STYLE_MAX    };    PRBool StyleVariantToColor(nsIVariant* aStyle, PRInt32 aWhichStyle);    void StyleColorToString(const nscolor& aColor, nsAString& aStr);    void DirtyAllStyles();    void ApplyStyle(PRInt32 aWhichStyle);    // Member vars    PRInt32 mWidth, mHeight;    // the canvas element informs us when it's going away,    // so these are not nsCOMPtrs    nsICanvasElement* mCanvasElement;    // image bits    nsCOMPtr<gfxIImageFrame> mImageFrame;    PRBool mDirty;    // our CSS parser, for colors and whatnot    nsCOMPtr<nsICSSParser> mCSSParser;    // yay cairo    PRUint32 mSaveCount;    cairo_t *mCairo;    cairo_surface_t *mSurface;    unsigned char *mSurfaceData;    float mGlobalAlpha;    // style handling    PRInt32 mLastStyle;    PRPackedBool mDirtyStyle[STYLE_MAX];    nscolor mColorStyles[STYLE_STACK_DEPTH][STYLE_MAX];    nsCOMPtr<nsCanvasGradient> mGradientStyles[STYLE_STACK_DEPTH][STYLE_MAX];    nsCOMPtr<nsCanvasPattern> mPatternStyles[STYLE_STACK_DEPTH][STYLE_MAX];    // stolen from nsJSUtils    static PRBool ConvertJSValToUint32(PRUint32* aProp, JSContext* aContext,                                       jsval aValue);    static PRBool ConvertJSValToXPCObject(nsISupports** aSupports, REFNSIID aIID,                                          JSContext* aContext, jsval aValue);    static PRBool ConvertJSValToDouble(double* aProp, JSContext* aContext,                                       jsval aValue);    // cairo helpers    nsresult CairoSurfaceFromElement(nsIDOMElement *imgElt,                                     cairo_surface_t **aCairoSurface,                                     PRUint8 **imgDataOut,                                     PRInt32 *widthOut, PRInt32 *heightOut);    nsresult DrawNativeSurfaces(nsIDrawingSurface* aBlackSurface,                                nsIDrawingSurface* aWhiteSurface,                                const nsIntSize& aSurfaceSize,                                nsIRenderingContext* aBlackContext);};