зеркало из https://github.com/mozilla/gecko-dev.git
Back out 438c192e561b and d6f341e77b68 (bug 762652, bug 762654) on suspicion of breaking Windows PGO tests
This commit is contained in:
Родитель
2055147352
Коммит
aa0f6555db
|
@ -129,14 +129,6 @@ protected:
|
|||
nsRefPtr<nsHTMLCanvasElement> mCanvasElement;
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
extern bool AzureCanvasEnabled();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasRenderingContextInternal,
|
||||
NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
|
|
|
@ -51,10 +51,6 @@ public:
|
|||
{
|
||||
return mHeight;
|
||||
}
|
||||
JSObject* GetData(JSContext* cx)
|
||||
{
|
||||
return GetDataObject();
|
||||
}
|
||||
JSObject* GetDataObject()
|
||||
{
|
||||
xpc_UnmarkGrayObject(mData);
|
||||
|
|
|
@ -77,7 +77,6 @@ INCLUDES += \
|
|||
-I$(srcdir)/../../../layout/generic \
|
||||
-I$(srcdir)/../../base/src \
|
||||
-I$(srcdir)/../../html/content/src \
|
||||
-I$(srcdir)/../../../js/xpconnect/src \
|
||||
-I$(srcdir)/../../../dom/base \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -1422,7 +1422,7 @@ nsCanvasRenderingContext2D::GetCanvas(nsIDOMHTMLCanvasElement **canvas)
|
|||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::MozSave()
|
||||
nsCanvasRenderingContext2D::Save()
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1435,7 +1435,7 @@ nsCanvasRenderingContext2D::MozSave()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::MozRestore()
|
||||
nsCanvasRenderingContext2D::Restore()
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1951,7 +1951,7 @@ nsCanvasRenderingContext2D::GetShadowBlur(float *blur)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D:: SetMozShadowColor(const nsAString& aColor)
|
||||
nsCanvasRenderingContext2D::SetShadowColor(const nsAString& aColor)
|
||||
{
|
||||
nscolor color;
|
||||
if (!ParseColor(aColor, &color)) {
|
||||
|
@ -1966,7 +1966,7 @@ nsCanvasRenderingContext2D:: SetMozShadowColor(const nsAString& aColor)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetMozShadowColor(nsAString& color)
|
||||
nsCanvasRenderingContext2D::GetShadowColor(nsAString& color)
|
||||
{
|
||||
StyleColorToString(CurrentState().colorStyles[STYLE_SHADOW], color);
|
||||
|
||||
|
@ -2217,7 +2217,7 @@ nsCanvasRenderingContext2D::StrokeRect(float x, float y, float w, float h)
|
|||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::MozBeginPath()
|
||||
nsCanvasRenderingContext2D::BeginPath()
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -2228,7 +2228,7 @@ nsCanvasRenderingContext2D::MozBeginPath()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::MozClosePath()
|
||||
nsCanvasRenderingContext2D::ClosePath()
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -2238,7 +2238,7 @@ nsCanvasRenderingContext2D::MozClosePath()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::MozFill()
|
||||
nsCanvasRenderingContext2D::Fill()
|
||||
{
|
||||
gfxRect dirty;
|
||||
nsresult rv = DrawPath(STYLE_FILL, &dirty);
|
||||
|
@ -2248,7 +2248,7 @@ nsCanvasRenderingContext2D::MozFill()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::MozStroke()
|
||||
nsCanvasRenderingContext2D::Stroke()
|
||||
{
|
||||
gfxRect dirty;
|
||||
nsresult rv = DrawPath(STYLE_STROKE, &dirty);
|
||||
|
@ -2258,7 +2258,7 @@ nsCanvasRenderingContext2D::MozStroke()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::MozClip()
|
||||
nsCanvasRenderingContext2D::Clip()
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -2487,7 +2487,7 @@ CreateFontStyleRule(const nsAString& aFont,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetMozFont(const nsAString& font)
|
||||
nsCanvasRenderingContext2D::SetFont(const nsAString& font)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -2616,7 +2616,7 @@ nsCanvasRenderingContext2D::SetMozFont(const nsAString& font)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetMozFont(nsAString& font)
|
||||
nsCanvasRenderingContext2D::GetFont(nsAString& font)
|
||||
{
|
||||
/* will initilize the value if not set, else does nothing */
|
||||
GetCurrentFontStyle();
|
||||
|
@ -2626,7 +2626,7 @@ nsCanvasRenderingContext2D::GetMozFont(nsAString& font)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetMozTextAlign(const nsAString& ta)
|
||||
nsCanvasRenderingContext2D::SetTextAlign(const nsAString& ta)
|
||||
{
|
||||
if (ta.EqualsLiteral("start"))
|
||||
CurrentState().textAlign = TEXT_ALIGN_START;
|
||||
|
@ -2643,7 +2643,7 @@ nsCanvasRenderingContext2D::SetMozTextAlign(const nsAString& ta)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetMozTextAlign(nsAString& ta)
|
||||
nsCanvasRenderingContext2D::GetTextAlign(nsAString& ta)
|
||||
{
|
||||
switch (CurrentState().textAlign)
|
||||
{
|
||||
|
@ -2668,7 +2668,7 @@ nsCanvasRenderingContext2D::GetMozTextAlign(nsAString& ta)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetMozTextBaseline(const nsAString& tb)
|
||||
nsCanvasRenderingContext2D::SetTextBaseline(const nsAString& tb)
|
||||
{
|
||||
if (tb.EqualsLiteral("top"))
|
||||
CurrentState().textBaseline = TEXT_BASELINE_TOP;
|
||||
|
@ -2687,7 +2687,7 @@ nsCanvasRenderingContext2D::SetMozTextBaseline(const nsAString& tb)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetMozTextBaseline(nsAString& tb)
|
||||
nsCanvasRenderingContext2D::GetTextBaseline(nsAString& tb)
|
||||
{
|
||||
switch (CurrentState().textBaseline)
|
||||
{
|
||||
|
@ -3114,17 +3114,17 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetTextStyle(const nsAString& textStyle)
|
||||
nsCanvasRenderingContext2D::SetMozTextStyle(const nsAString& textStyle)
|
||||
{
|
||||
// font and mozTextStyle are the same value
|
||||
return SetMozFont(textStyle);
|
||||
return SetFont(textStyle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetTextStyle(nsAString& textStyle)
|
||||
nsCanvasRenderingContext2D::GetMozTextStyle(nsAString& textStyle)
|
||||
{
|
||||
// font and mozTextStyle are the same value
|
||||
return GetMozFont(textStyle);
|
||||
return GetFont(textStyle);
|
||||
}
|
||||
|
||||
gfxFontGroup*
|
||||
|
@ -3132,7 +3132,7 @@ nsCanvasRenderingContext2D::GetCurrentFontStyle()
|
|||
{
|
||||
// use lazy initilization for the font group since it's rather expensive
|
||||
if(!CurrentState().fontGroup) {
|
||||
nsresult rv = SetTextStyle(kDefaultFontStyle);
|
||||
nsresult rv = SetMozTextStyle(kDefaultFontStyle);
|
||||
if (NS_FAILED(rv)) {
|
||||
gfxFontStyle style;
|
||||
style.size = kDefaultFontSize;
|
||||
|
@ -3197,7 +3197,7 @@ nsCanvasRenderingContext2D::GetLineWidth(float *width)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetMozLineCap(const nsAString& capstyle)
|
||||
nsCanvasRenderingContext2D::SetLineCap(const nsAString& capstyle)
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3219,7 +3219,7 @@ nsCanvasRenderingContext2D::SetMozLineCap(const nsAString& capstyle)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetMozLineCap(nsAString& capstyle)
|
||||
nsCanvasRenderingContext2D::GetLineCap(nsAString& capstyle)
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3239,7 +3239,7 @@ nsCanvasRenderingContext2D::GetMozLineCap(nsAString& capstyle)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::SetMozLineJoin(const nsAString& joinstyle)
|
||||
nsCanvasRenderingContext2D::SetLineJoin(const nsAString& joinstyle)
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3261,7 +3261,7 @@ nsCanvasRenderingContext2D::SetMozLineJoin(const nsAString& joinstyle)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCanvasRenderingContext2D::GetMozLineJoin(nsAString& joinstyle)
|
||||
nsCanvasRenderingContext2D::GetLineJoin(nsAString& joinstyle)
|
||||
{
|
||||
if (!EnsureSurface())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,943 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsCanvasRenderingContext2DAzure_h
|
||||
#define nsCanvasRenderingContext2DAzure_h
|
||||
|
||||
#include <vector>
|
||||
#include "nsIDOMCanvasRenderingContext2D.h"
|
||||
#include "nsICanvasRenderingContextInternal.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsHTMLCanvasElement.h"
|
||||
#include "CanvasUtils.h"
|
||||
#include "nsHTMLImageElement.h"
|
||||
#include "nsHTMLVideoElement.h"
|
||||
#include "gfxFont.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
template<typename T> class Optional;
|
||||
}
|
||||
namespace gfx {
|
||||
struct Rect;
|
||||
class SourceSurface;
|
||||
}
|
||||
}
|
||||
|
||||
extern const mozilla::gfx::Float SIGMA_MAX;
|
||||
|
||||
/**
|
||||
** nsCanvasGradientAzure
|
||||
**/
|
||||
#define NS_CANVASGRADIENTAZURE_PRIVATE_IID \
|
||||
{0x28425a6a, 0x90e0, 0x4d42, {0x9c, 0x75, 0xff, 0x60, 0x09, 0xb3, 0x10, 0xa8}}
|
||||
class nsCanvasGradientAzure : public nsIDOMCanvasGradient
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CANVASGRADIENTAZURE_PRIVATE_IID)
|
||||
|
||||
enum Type
|
||||
{
|
||||
LINEAR = 0,
|
||||
RADIAL
|
||||
};
|
||||
|
||||
Type GetType()
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
|
||||
|
||||
mozilla::gfx::GradientStops *
|
||||
GetGradientStopsForTarget(mozilla::gfx::DrawTarget *aRT)
|
||||
{
|
||||
if (mStops && mStops->GetBackendType() == aRT->GetType()) {
|
||||
return mStops;
|
||||
}
|
||||
|
||||
mStops = aRT->CreateGradientStops(mRawStops.Elements(), mRawStops.Length());
|
||||
|
||||
return mStops;
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* nsIDOMCanvasGradient */
|
||||
NS_IMETHOD AddColorStop(float offset, const nsAString& colorstr);
|
||||
|
||||
protected:
|
||||
nsCanvasGradientAzure(Type aType) : mType(aType)
|
||||
{}
|
||||
|
||||
nsTArray<mozilla::gfx::GradientStop> mRawStops;
|
||||
mozilla::RefPtr<mozilla::gfx::GradientStops> mStops;
|
||||
Type mType;
|
||||
virtual ~nsCanvasGradientAzure() {}
|
||||
};
|
||||
|
||||
/**
|
||||
** nsCanvasPatternAzure
|
||||
**/
|
||||
#define NS_CANVASPATTERNAZURE_PRIVATE_IID \
|
||||
{0xc9bacc25, 0x28da, 0x421e, {0x9a, 0x4b, 0xbb, 0xd6, 0x93, 0x05, 0x12, 0xbc}}
|
||||
class nsCanvasPatternAzure MOZ_FINAL : public nsIDOMCanvasPattern
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CANVASPATTERNAZURE_PRIVATE_IID)
|
||||
|
||||
enum RepeatMode
|
||||
{
|
||||
REPEAT,
|
||||
REPEATX,
|
||||
REPEATY,
|
||||
NOREPEAT
|
||||
};
|
||||
|
||||
nsCanvasPatternAzure(mozilla::gfx::SourceSurface* aSurface,
|
||||
RepeatMode aRepeat,
|
||||
nsIPrincipal* principalForSecurityCheck,
|
||||
bool forceWriteOnly,
|
||||
bool CORSUsed)
|
||||
: mSurface(aSurface)
|
||||
, mRepeat(aRepeat)
|
||||
, mPrincipal(principalForSecurityCheck)
|
||||
, mForceWriteOnly(forceWriteOnly)
|
||||
, mCORSUsed(CORSUsed)
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
mozilla::RefPtr<mozilla::gfx::SourceSurface> mSurface;
|
||||
const RepeatMode mRepeat;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
const bool mForceWriteOnly;
|
||||
const bool mCORSUsed;
|
||||
};
|
||||
|
||||
struct nsCanvasBidiProcessorAzure;
|
||||
class CanvasRenderingContext2DUserDataAzure;
|
||||
|
||||
/**
|
||||
** nsCanvasRenderingContext2DAzure
|
||||
**/
|
||||
class nsCanvasRenderingContext2DAzure :
|
||||
public nsIDOMCanvasRenderingContext2D,
|
||||
public nsICanvasRenderingContextInternal,
|
||||
public nsWrapperCache
|
||||
{
|
||||
typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
|
||||
HTMLImageOrCanvasOrVideoElement;
|
||||
|
||||
public:
|
||||
nsCanvasRenderingContext2DAzure();
|
||||
virtual ~nsCanvasRenderingContext2DAzure();
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap);
|
||||
|
||||
nsHTMLCanvasElement* GetCanvas() const
|
||||
{
|
||||
return mCanvasElement;
|
||||
}
|
||||
|
||||
void Save();
|
||||
void Restore();
|
||||
void Scale(double x, double y, mozilla::ErrorResult& error);
|
||||
void Rotate(double angle, mozilla::ErrorResult& error);
|
||||
void Translate(double x, double y, mozilla::ErrorResult& error);
|
||||
void Transform(double m11, double m12, double m21, double m22, double dx,
|
||||
double dy, mozilla::ErrorResult& error);
|
||||
void SetTransform(double m11, double m12, double m21, double m22, double dx,
|
||||
double dy, mozilla::ErrorResult& error);
|
||||
|
||||
double GetGlobalAlpha()
|
||||
{
|
||||
return CurrentState().globalAlpha;
|
||||
}
|
||||
|
||||
void SetGlobalAlpha(double globalAlpha)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(globalAlpha) &&
|
||||
globalAlpha >= 0.0 && globalAlpha <= 1.0) {
|
||||
CurrentState().globalAlpha = globalAlpha;
|
||||
}
|
||||
}
|
||||
|
||||
void GetGlobalCompositeOperation(nsAString& op, mozilla::ErrorResult& error);
|
||||
void SetGlobalCompositeOperation(const nsAString& op,
|
||||
mozilla::ErrorResult& error);
|
||||
JS::Value GetStrokeStyle(JSContext* cx, mozilla::ErrorResult& error);
|
||||
|
||||
void SetStrokeStyle(JSContext* cx, JS::Value& value)
|
||||
{
|
||||
SetStyleFromJSValue(cx, value, STYLE_STROKE);
|
||||
}
|
||||
|
||||
JS::Value GetFillStyle(JSContext* cx, mozilla::ErrorResult& error);
|
||||
|
||||
void SetFillStyle(JSContext* cx, JS::Value& value)
|
||||
{
|
||||
SetStyleFromJSValue(cx, value, STYLE_FILL);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMCanvasGradient>
|
||||
CreateLinearGradient(double x0, double y0, double x1, double y1,
|
||||
mozilla::ErrorResult& aError);
|
||||
already_AddRefed<nsIDOMCanvasGradient>
|
||||
CreateRadialGradient(double x0, double y0, double r0, double x1, double y1,
|
||||
double r1, mozilla::ErrorResult& aError);
|
||||
already_AddRefed<nsIDOMCanvasPattern>
|
||||
CreatePattern(const HTMLImageOrCanvasOrVideoElement& element,
|
||||
const nsAString& repeat, mozilla::ErrorResult& error);
|
||||
|
||||
double GetShadowOffsetX()
|
||||
{
|
||||
return CurrentState().shadowOffset.x;
|
||||
}
|
||||
|
||||
void SetShadowOffsetX(double shadowOffsetX)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(shadowOffsetX)) {
|
||||
CurrentState().shadowOffset.x = shadowOffsetX;
|
||||
}
|
||||
}
|
||||
|
||||
double GetShadowOffsetY()
|
||||
{
|
||||
return CurrentState().shadowOffset.y;
|
||||
}
|
||||
|
||||
void SetShadowOffsetY(double shadowOffsetY)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(shadowOffsetY)) {
|
||||
CurrentState().shadowOffset.y = shadowOffsetY;
|
||||
}
|
||||
}
|
||||
|
||||
double GetShadowBlur()
|
||||
{
|
||||
return CurrentState().shadowBlur;
|
||||
}
|
||||
|
||||
void SetShadowBlur(double shadowBlur)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(shadowBlur) && shadowBlur >= 0.0) {
|
||||
CurrentState().shadowBlur = shadowBlur;
|
||||
}
|
||||
}
|
||||
|
||||
void GetShadowColor(nsAString& shadowColor)
|
||||
{
|
||||
StyleColorToString(CurrentState().shadowColor, shadowColor);
|
||||
}
|
||||
|
||||
void SetShadowColor(const nsAString& shadowColor);
|
||||
void ClearRect(double x, double y, double w, double h);
|
||||
void FillRect(double x, double y, double w, double h);
|
||||
void StrokeRect(double x, double y, double w, double h);
|
||||
void BeginPath();
|
||||
void Fill();
|
||||
void Stroke();
|
||||
void Clip();
|
||||
bool IsPointInPath(double x, double y);
|
||||
void FillText(const nsAString& text, double x, double y,
|
||||
const mozilla::dom::Optional<double>& maxWidth,
|
||||
mozilla::ErrorResult& error);
|
||||
void StrokeText(const nsAString& text, double x, double y,
|
||||
const mozilla::dom::Optional<double>& maxWidth,
|
||||
mozilla::ErrorResult& error);
|
||||
already_AddRefed<nsIDOMTextMetrics>
|
||||
MeasureText(const nsAString& rawText, mozilla::ErrorResult& error);
|
||||
|
||||
void DrawImage(const HTMLImageOrCanvasOrVideoElement& image,
|
||||
double dx, double dy, mozilla::ErrorResult& error)
|
||||
{
|
||||
if (!mozilla::CanvasUtils::FloatValidate(dx, dy)) {
|
||||
return;
|
||||
}
|
||||
DrawImage(image, 0.0, 0.0, 0.0, 0.0, dx, dy, 0.0, 0.0, 0, error);
|
||||
}
|
||||
|
||||
void DrawImage(const HTMLImageOrCanvasOrVideoElement& image,
|
||||
double dx, double dy, double dw, double dh,
|
||||
mozilla::ErrorResult& error)
|
||||
{
|
||||
if (!mozilla::CanvasUtils::FloatValidate(dx, dy, dw, dh)) {
|
||||
return;
|
||||
}
|
||||
DrawImage(image, 0.0, 0.0, 0.0, 0.0, dx, dy, dw, dh, 2, error);
|
||||
}
|
||||
|
||||
void DrawImage(const HTMLImageOrCanvasOrVideoElement& image,
|
||||
double sx, double sy, double sw, double sh, double dx,
|
||||
double dy, double dw, double dh, mozilla::ErrorResult& error)
|
||||
{
|
||||
if (!mozilla::CanvasUtils::FloatValidate(sx, sy, sw, sh) ||
|
||||
!mozilla::CanvasUtils::FloatValidate(dx, dy, dw, dh)) {
|
||||
return;
|
||||
}
|
||||
DrawImage(image, sx, sy, sw, sh, dx, dy, dw, dh, 6, error);
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::ImageData>
|
||||
CreateImageData(JSContext* cx, double sw, double sh,
|
||||
mozilla::ErrorResult& error);
|
||||
already_AddRefed<mozilla::dom::ImageData>
|
||||
CreateImageData(JSContext* cx, mozilla::dom::ImageData* imagedata,
|
||||
mozilla::ErrorResult& error);
|
||||
already_AddRefed<mozilla::dom::ImageData>
|
||||
GetImageData(JSContext* cx, double sx, double sy, double sw, double sh,
|
||||
mozilla::ErrorResult& error);
|
||||
void PutImageData(JSContext* cx, mozilla::dom::ImageData* imageData,
|
||||
double dx, double dy, mozilla::ErrorResult& error);
|
||||
void PutImageData(JSContext* cx, mozilla::dom::ImageData* imageData,
|
||||
double dx, double dy, double dirtyX, double dirtyY,
|
||||
double dirtyWidth, double dirtyHeight,
|
||||
mozilla::ErrorResult& error);
|
||||
|
||||
double GetLineWidth()
|
||||
{
|
||||
return CurrentState().lineWidth;
|
||||
}
|
||||
|
||||
void SetLineWidth(double width)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(width) && width > 0.0) {
|
||||
CurrentState().lineWidth = width;
|
||||
}
|
||||
}
|
||||
void GetLineCap(nsAString& linecap);
|
||||
void SetLineCap(const nsAString& linecap);
|
||||
void GetLineJoin(nsAString& linejoin, mozilla::ErrorResult& error);
|
||||
void SetLineJoin(const nsAString& linejoin);
|
||||
|
||||
double GetMiterLimit()
|
||||
{
|
||||
return CurrentState().miterLimit;
|
||||
}
|
||||
|
||||
void SetMiterLimit(double miter)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(miter) && miter > 0.0) {
|
||||
CurrentState().miterLimit = miter;
|
||||
}
|
||||
}
|
||||
|
||||
void GetFont(nsAString& font)
|
||||
{
|
||||
font = GetFont();
|
||||
}
|
||||
|
||||
void SetFont(const nsAString& font, mozilla::ErrorResult& error);
|
||||
void GetTextAlign(nsAString& textAlign);
|
||||
void SetTextAlign(const nsAString& textAlign);
|
||||
void GetTextBaseline(nsAString& textBaseline);
|
||||
void SetTextBaseline(const nsAString& textBaseline);
|
||||
|
||||
void ClosePath()
|
||||
{
|
||||
EnsureWritablePath();
|
||||
|
||||
if (mPathBuilder) {
|
||||
mPathBuilder->Close();
|
||||
} else {
|
||||
mDSPathBuilder->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void MoveTo(double x, double y)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(x, y)) {
|
||||
EnsureWritablePath();
|
||||
|
||||
if (mPathBuilder) {
|
||||
mPathBuilder->MoveTo(mozilla::gfx::Point(x, y));
|
||||
} else {
|
||||
mDSPathBuilder->MoveTo(mTarget->GetTransform() *
|
||||
mozilla::gfx::Point(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LineTo(double x, double y)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(x, y)) {
|
||||
EnsureWritablePath();
|
||||
|
||||
LineTo(mozilla::gfx::Point(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
void QuadraticCurveTo(double cpx, double cpy, double x, double y)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(cpx, cpy, x, y)) {
|
||||
EnsureWritablePath();
|
||||
|
||||
if (mPathBuilder) {
|
||||
mPathBuilder->QuadraticBezierTo(mozilla::gfx::Point(cpx, cpy),
|
||||
mozilla::gfx::Point(x, y));
|
||||
} else {
|
||||
mozilla::gfx::Matrix transform = mTarget->GetTransform();
|
||||
mDSPathBuilder->QuadraticBezierTo(transform *
|
||||
mozilla::gfx::Point(cpx, cpy),
|
||||
transform *
|
||||
mozilla::gfx::Point(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y)
|
||||
{
|
||||
if (mozilla::CanvasUtils::FloatValidate(cp1x, cp1y, cp2x, cp2y, x, y)) {
|
||||
EnsureWritablePath();
|
||||
|
||||
BezierTo(mozilla::gfx::Point(cp1x, cp1y),
|
||||
mozilla::gfx::Point(cp2x, cp2y),
|
||||
mozilla::gfx::Point(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
void ArcTo(double x1, double y1, double x2, double y2, double radius,
|
||||
mozilla::ErrorResult& error);
|
||||
void Rect(double x, double y, double w, double h);
|
||||
void Arc(double x, double y, double radius, double startAngle,
|
||||
double endAngle, bool anticlockwise, mozilla::ErrorResult& error);
|
||||
|
||||
JSObject* GetMozCurrentTransform(JSContext* cx,
|
||||
mozilla::ErrorResult& error) const;
|
||||
void SetMozCurrentTransform(JSContext* cx, JSObject& currentTransform,
|
||||
mozilla::ErrorResult& error);
|
||||
JSObject* GetMozCurrentTransformInverse(JSContext* cx,
|
||||
mozilla::ErrorResult& error) const;
|
||||
void SetMozCurrentTransformInverse(JSContext* cx, JSObject& currentTransform,
|
||||
mozilla::ErrorResult& error);
|
||||
void GetFillRule(nsAString& fillRule);
|
||||
void SetFillRule(const nsAString& fillRule);
|
||||
JS::Value GetMozDash(JSContext* cx, mozilla::ErrorResult& error);
|
||||
void SetMozDash(JSContext* cx, const JS::Value& mozDash,
|
||||
mozilla::ErrorResult& error);
|
||||
|
||||
double GetMozDashOffset()
|
||||
{
|
||||
return CurrentState().dashOffset;
|
||||
}
|
||||
|
||||
void SetMozDashOffset(double mozDashOffset, mozilla::ErrorResult& error);
|
||||
|
||||
void GetMozTextStyle(nsAString& mozTextStyle)
|
||||
{
|
||||
GetFont(mozTextStyle);
|
||||
}
|
||||
|
||||
void SetMozTextStyle(const nsAString& mozTextStyle,
|
||||
mozilla::ErrorResult& error)
|
||||
{
|
||||
SetFont(mozTextStyle, error);
|
||||
}
|
||||
|
||||
bool GetImageSmoothingEnabled()
|
||||
{
|
||||
return CurrentState().imageSmoothingEnabled;
|
||||
}
|
||||
|
||||
void SetImageSmoothingEnabled(bool imageSmoothingEnabled)
|
||||
{
|
||||
if (imageSmoothingEnabled != CurrentState().imageSmoothingEnabled) {
|
||||
CurrentState().imageSmoothingEnabled = imageSmoothingEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWindow(nsIDOMWindow* window, double x, double y, double w, double h,
|
||||
const nsAString& bgColor, uint32_t flags,
|
||||
mozilla::ErrorResult& error);
|
||||
void AsyncDrawXULElement(nsIDOMXULElement* elem, double x, double y, double w,
|
||||
double h, const nsAString& bgColor, uint32_t flags,
|
||||
mozilla::ErrorResult& error);
|
||||
|
||||
nsresult Redraw();
|
||||
|
||||
// nsICanvasRenderingContextInternal
|
||||
NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height);
|
||||
NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, PRInt32 width, PRInt32 height)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHOD Render(gfxContext *ctx,
|
||||
gfxPattern::GraphicsFilter aFilter,
|
||||
PRUint32 aFlags = RenderFlagPremultAlpha);
|
||||
NS_IMETHOD GetInputStream(const char* aMimeType,
|
||||
const PRUnichar* aEncoderOptions,
|
||||
nsIInputStream **aStream);
|
||||
NS_IMETHOD GetThebesSurface(gfxASurface **surface);
|
||||
|
||||
mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot()
|
||||
{ return mTarget ? mTarget->Snapshot() : nsnull; }
|
||||
|
||||
NS_IMETHOD SetIsOpaque(bool isOpaque);
|
||||
NS_IMETHOD Reset();
|
||||
already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
||||
CanvasLayer *aOldLayer,
|
||||
LayerManager *aManager);
|
||||
void MarkContextClean();
|
||||
NS_IMETHOD SetIsIPC(bool isIPC);
|
||||
// this rect is in canvas device space
|
||||
void Redraw(const mozilla::gfx::Rect &r);
|
||||
NS_IMETHOD Redraw(const gfxRect &r) { Redraw(ToRect(r)); return NS_OK; }
|
||||
|
||||
// this rect is in mTarget's current user space
|
||||
void RedrawUser(const gfxRect &r);
|
||||
|
||||
// nsISupports interface + CC
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCanvasRenderingContext2DAzure,
|
||||
nsIDOMCanvasRenderingContext2D)
|
||||
|
||||
// nsIDOMCanvasRenderingContext2D interface
|
||||
NS_DECL_NSIDOMCANVASRENDERINGCONTEXT2D
|
||||
|
||||
enum Style {
|
||||
STYLE_STROKE = 0,
|
||||
STYLE_FILL,
|
||||
STYLE_MAX
|
||||
};
|
||||
|
||||
nsINode* GetParentObject()
|
||||
{
|
||||
return mCanvasElement;
|
||||
}
|
||||
|
||||
void LineTo(const mozilla::gfx::Point& aPoint)
|
||||
{
|
||||
if (mPathBuilder) {
|
||||
mPathBuilder->LineTo(aPoint);
|
||||
} else {
|
||||
mDSPathBuilder->LineTo(mTarget->GetTransform() * aPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void BezierTo(const mozilla::gfx::Point& aCP1,
|
||||
const mozilla::gfx::Point& aCP2,
|
||||
const mozilla::gfx::Point& aCP3)
|
||||
{
|
||||
if (mPathBuilder) {
|
||||
mPathBuilder->BezierTo(aCP1, aCP2, aCP3);
|
||||
} else {
|
||||
mozilla::gfx::Matrix transform = mTarget->GetTransform();
|
||||
mDSPathBuilder->BezierTo(transform * aCP1,
|
||||
transform * aCP2,
|
||||
transform * aCP3);
|
||||
}
|
||||
}
|
||||
|
||||
friend class CanvasRenderingContext2DUserDataAzure;
|
||||
|
||||
protected:
|
||||
nsresult GetImageDataArray(JSContext* aCx, int32_t aX, int32_t aY,
|
||||
uint32_t aWidth, uint32_t aHeight,
|
||||
JSObject** aRetval);
|
||||
|
||||
nsresult InitializeWithTarget(mozilla::gfx::DrawTarget *surface,
|
||||
PRInt32 width, PRInt32 height);
|
||||
|
||||
/**
|
||||
* The number of living nsCanvasRenderingContexts. When this goes down to
|
||||
* 0, we free the premultiply and unpremultiply tables, if they exist.
|
||||
*/
|
||||
static PRUint32 sNumLivingContexts;
|
||||
|
||||
/**
|
||||
* Lookup table used to speed up GetImageData().
|
||||
*/
|
||||
static PRUint8 (*sUnpremultiplyTable)[256];
|
||||
|
||||
/**
|
||||
* Lookup table used to speed up PutImageData().
|
||||
*/
|
||||
static PRUint8 (*sPremultiplyTable)[256];
|
||||
|
||||
// Some helpers. Doesn't modify a color on failure.
|
||||
void SetStyleFromJSValue(JSContext* cx, JS::Value& value, Style whichStyle);
|
||||
void SetStyleFromString(const nsAString& str, Style whichStyle);
|
||||
|
||||
void SetStyleFromGradient(nsCanvasGradientAzure *gradient, Style whichStyle)
|
||||
{
|
||||
CurrentState().SetGradientStyle(whichStyle, gradient);
|
||||
}
|
||||
|
||||
void SetStyleFromPattern(nsCanvasPatternAzure *pattern, Style whichStyle)
|
||||
{
|
||||
CurrentState().SetPatternStyle(whichStyle, pattern);
|
||||
}
|
||||
|
||||
void SetStyleFromStringOrInterface(const nsAString& aStr, nsISupports *aInterface, Style aWhichStyle);
|
||||
nsISupports* GetStyleAsStringOrInterface(nsAString& aStr, CanvasMultiGetterType& aType, Style aWhichStyle);
|
||||
|
||||
// Returns whether a color was successfully parsed.
|
||||
bool ParseColor(const nsAString& aString, nscolor* aColor);
|
||||
|
||||
static void StyleColorToString(const nscolor& aColor, nsAString& aStr);
|
||||
|
||||
/**
|
||||
* Creates the unpremultiply lookup table, if it doesn't exist.
|
||||
*/
|
||||
void EnsureUnpremultiplyTable();
|
||||
|
||||
/**
|
||||
* Creates the premultiply lookup table, if it doesn't exist.
|
||||
*/
|
||||
void EnsurePremultiplyTable();
|
||||
|
||||
/* This function ensures there is a writable pathbuilder available, this
|
||||
* pathbuilder may be working in user space or in device space or
|
||||
* device space.
|
||||
*/
|
||||
void EnsureWritablePath();
|
||||
|
||||
// Ensures a path in UserSpace is available.
|
||||
void EnsureUserSpacePath();
|
||||
|
||||
void TransformWillUpdate();
|
||||
|
||||
// Report the fillRule has changed.
|
||||
void FillRuleChanged();
|
||||
|
||||
/**
|
||||
* Returns the surface format this canvas should be allocated using. Takes
|
||||
* into account mOpaque, platform requirements, etc.
|
||||
*/
|
||||
mozilla::gfx::SurfaceFormat GetSurfaceFormat() const;
|
||||
|
||||
void DrawImage(const HTMLImageOrCanvasOrVideoElement &imgElt,
|
||||
double sx, double sy, double sw, double sh,
|
||||
double dx, double dy, double dw, double dh,
|
||||
PRUint8 optional_argc, mozilla::ErrorResult& error);
|
||||
|
||||
nsString& GetFont()
|
||||
{
|
||||
/* will initilize the value if not set, else does nothing */
|
||||
GetCurrentFontStyle();
|
||||
|
||||
return CurrentState().font;
|
||||
}
|
||||
|
||||
static bool
|
||||
ToHTMLImageOrCanvasOrVideoElement(nsIDOMElement* html,
|
||||
HTMLImageOrCanvasOrVideoElement& element)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(html);
|
||||
if (content) {
|
||||
if (content->IsHTML(nsGkAtoms::canvas)) {
|
||||
element.SetAsHTMLCanvasElement() =
|
||||
static_cast<nsHTMLCanvasElement*>(html);
|
||||
return true;
|
||||
}
|
||||
if (content->IsHTML(nsGkAtoms::img)) {
|
||||
element.SetAsHTMLImageElement() =
|
||||
static_cast<nsHTMLImageElement*>(html);
|
||||
return true;
|
||||
}
|
||||
if (content->IsHTML(nsGkAtoms::video)) {
|
||||
element.SetAsHTMLVideoElement() =
|
||||
static_cast<nsHTMLVideoElement*>(html);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Member vars
|
||||
PRInt32 mWidth, mHeight;
|
||||
|
||||
// This is true when the canvas is valid, false otherwise, this occurs when
|
||||
// for some reason initialization of the drawtarget fails. If the canvas
|
||||
// is invalid certain behavior is expected.
|
||||
bool mValid;
|
||||
// This is true when the canvas is valid, but of zero size, this requires
|
||||
// specific behavior on some operations.
|
||||
bool mZero;
|
||||
|
||||
bool mOpaque;
|
||||
|
||||
// This is true when the next time our layer is retrieved we need to
|
||||
// recreate it (i.e. our backing surface changed)
|
||||
bool mResetLayer;
|
||||
// This is needed for drawing in drawAsyncXULElement
|
||||
bool mIPC;
|
||||
|
||||
nsTArray<CanvasRenderingContext2DUserDataAzure*> mUserDatas;
|
||||
|
||||
// If mCanvasElement is not provided, then a docshell is
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
|
||||
// our drawing surfaces, contexts, and layers
|
||||
mozilla::RefPtr<mozilla::gfx::DrawTarget> mTarget;
|
||||
|
||||
/**
|
||||
* Flag to avoid duplicate calls to InvalidateFrame. Set to true whenever
|
||||
* Redraw is called, reset to false when Render is called.
|
||||
*/
|
||||
bool mIsEntireFrameInvalid;
|
||||
/**
|
||||
* When this is set, the first call to Redraw(gfxRect) should set
|
||||
* mIsEntireFrameInvalid since we expect it will be followed by
|
||||
* many more Redraw calls.
|
||||
*/
|
||||
bool mPredictManyRedrawCalls;
|
||||
|
||||
// This is stored after GetThebesSurface has been called once to avoid
|
||||
// excessive ThebesSurface initialization overhead.
|
||||
nsRefPtr<gfxASurface> mThebesSurface;
|
||||
|
||||
/**
|
||||
* We also have a device space pathbuilder. The reason for this is as
|
||||
* follows, when a path is being built, but the transform changes, we
|
||||
* can no longer keep a single path in userspace, considering there's
|
||||
* several 'user spaces' now. We therefore transform the current path
|
||||
* into device space, and add all operations to this path in device
|
||||
* space.
|
||||
*
|
||||
* When then finally executing a render, the Azure drawing API expects
|
||||
* the path to be in userspace. We could then set an identity transform
|
||||
* on the DrawTarget and do all drawing in device space. This is
|
||||
* undesirable because it requires transforming patterns, gradients,
|
||||
* clips, etc. into device space and it would not work for stroking.
|
||||
* What we do instead is convert the path back to user space when it is
|
||||
* drawn, and draw it with the current transform. This makes all drawing
|
||||
* occur correctly.
|
||||
*
|
||||
* There's never both a device space path builder and a user space path
|
||||
* builder present at the same time. There is also never a path and a
|
||||
* path builder present at the same time. When writing proceeds on an
|
||||
* existing path the Path is cleared and a new builder is created.
|
||||
*
|
||||
* mPath is always in user-space.
|
||||
*/
|
||||
mozilla::RefPtr<mozilla::gfx::Path> mPath;
|
||||
mozilla::RefPtr<mozilla::gfx::PathBuilder> mDSPathBuilder;
|
||||
mozilla::RefPtr<mozilla::gfx::PathBuilder> mPathBuilder;
|
||||
bool mPathTransformWillUpdate;
|
||||
mozilla::gfx::Matrix mPathToDS;
|
||||
|
||||
/**
|
||||
* Number of times we've invalidated before calling redraw
|
||||
*/
|
||||
PRUint32 mInvalidateCount;
|
||||
static const PRUint32 kCanvasMaxInvalidateCount = 100;
|
||||
|
||||
/**
|
||||
* Returns true if a shadow should be drawn along with a
|
||||
* drawing operation.
|
||||
*/
|
||||
bool NeedToDrawShadow()
|
||||
{
|
||||
const ContextState& state = CurrentState();
|
||||
|
||||
// The spec says we should not draw shadows if the operator is OVER.
|
||||
// If it's over and the alpha value is zero, nothing needs to be drawn.
|
||||
return NS_GET_A(state.shadowColor) != 0 &&
|
||||
(state.shadowBlur != 0 || state.shadowOffset.x != 0 || state.shadowOffset.y != 0);
|
||||
}
|
||||
|
||||
mozilla::gfx::CompositionOp UsedOperation()
|
||||
{
|
||||
if (NeedToDrawShadow()) {
|
||||
// In this case the shadow rendering will use the operator.
|
||||
return mozilla::gfx::OP_OVER;
|
||||
}
|
||||
|
||||
return CurrentState().op;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pres shell from either the canvas element or the doc shell
|
||||
*/
|
||||
nsIPresShell *GetPresShell() {
|
||||
if (mCanvasElement) {
|
||||
return mCanvasElement->OwnerDoc()->GetShell();
|
||||
}
|
||||
if (mDocShell) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocShell->GetPresShell(getter_AddRefs(shell));
|
||||
return shell.get();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// text
|
||||
enum TextAlign {
|
||||
TEXT_ALIGN_START,
|
||||
TEXT_ALIGN_END,
|
||||
TEXT_ALIGN_LEFT,
|
||||
TEXT_ALIGN_RIGHT,
|
||||
TEXT_ALIGN_CENTER
|
||||
};
|
||||
|
||||
enum TextBaseline {
|
||||
TEXT_BASELINE_TOP,
|
||||
TEXT_BASELINE_HANGING,
|
||||
TEXT_BASELINE_MIDDLE,
|
||||
TEXT_BASELINE_ALPHABETIC,
|
||||
TEXT_BASELINE_IDEOGRAPHIC,
|
||||
TEXT_BASELINE_BOTTOM
|
||||
};
|
||||
|
||||
gfxFontGroup *GetCurrentFontStyle();
|
||||
|
||||
enum TextDrawOperation {
|
||||
TEXT_DRAW_OPERATION_FILL,
|
||||
TEXT_DRAW_OPERATION_STROKE,
|
||||
TEXT_DRAW_OPERATION_MEASURE
|
||||
};
|
||||
|
||||
/*
|
||||
* Implementation of the fillText, strokeText, and measure functions with
|
||||
* the operation abstracted to a flag.
|
||||
*/
|
||||
nsresult DrawOrMeasureText(const nsAString& text,
|
||||
float x,
|
||||
float y,
|
||||
const mozilla::dom::Optional<double>& maxWidth,
|
||||
TextDrawOperation op,
|
||||
float* aWidth);
|
||||
|
||||
// state stack handling
|
||||
class ContextState {
|
||||
public:
|
||||
ContextState() : textAlign(TEXT_ALIGN_START),
|
||||
textBaseline(TEXT_BASELINE_ALPHABETIC),
|
||||
lineWidth(1.0f),
|
||||
miterLimit(10.0f),
|
||||
globalAlpha(1.0f),
|
||||
shadowBlur(0.0),
|
||||
dashOffset(0.0f),
|
||||
op(mozilla::gfx::OP_OVER),
|
||||
fillRule(mozilla::gfx::FILL_WINDING),
|
||||
lineCap(mozilla::gfx::CAP_BUTT),
|
||||
lineJoin(mozilla::gfx::JOIN_MITER_OR_BEVEL),
|
||||
imageSmoothingEnabled(true)
|
||||
{ }
|
||||
|
||||
ContextState(const ContextState& other)
|
||||
: fontGroup(other.fontGroup),
|
||||
font(other.font),
|
||||
textAlign(other.textAlign),
|
||||
textBaseline(other.textBaseline),
|
||||
shadowColor(other.shadowColor),
|
||||
transform(other.transform),
|
||||
shadowOffset(other.shadowOffset),
|
||||
lineWidth(other.lineWidth),
|
||||
miterLimit(other.miterLimit),
|
||||
globalAlpha(other.globalAlpha),
|
||||
shadowBlur(other.shadowBlur),
|
||||
dash(other.dash),
|
||||
dashOffset(other.dashOffset),
|
||||
op(other.op),
|
||||
fillRule(other.fillRule),
|
||||
lineCap(other.lineCap),
|
||||
lineJoin(other.lineJoin),
|
||||
imageSmoothingEnabled(other.imageSmoothingEnabled)
|
||||
{
|
||||
for (int i = 0; i < STYLE_MAX; i++) {
|
||||
colorStyles[i] = other.colorStyles[i];
|
||||
gradientStyles[i] = other.gradientStyles[i];
|
||||
patternStyles[i] = other.patternStyles[i];
|
||||
}
|
||||
}
|
||||
|
||||
void SetColorStyle(Style whichStyle, nscolor color) {
|
||||
colorStyles[whichStyle] = color;
|
||||
gradientStyles[whichStyle] = nsnull;
|
||||
patternStyles[whichStyle] = nsnull;
|
||||
}
|
||||
|
||||
void SetPatternStyle(Style whichStyle, nsCanvasPatternAzure* pat) {
|
||||
gradientStyles[whichStyle] = nsnull;
|
||||
patternStyles[whichStyle] = pat;
|
||||
}
|
||||
|
||||
void SetGradientStyle(Style whichStyle, nsCanvasGradientAzure* grad) {
|
||||
gradientStyles[whichStyle] = grad;
|
||||
patternStyles[whichStyle] = nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true iff the given style is a solid color.
|
||||
*/
|
||||
bool StyleIsColor(Style whichStyle) const
|
||||
{
|
||||
return !(patternStyles[whichStyle] || gradientStyles[whichStyle]);
|
||||
}
|
||||
|
||||
|
||||
std::vector<mozilla::RefPtr<mozilla::gfx::Path> > clipsPushed;
|
||||
|
||||
nsRefPtr<gfxFontGroup> fontGroup;
|
||||
nsRefPtr<nsCanvasGradientAzure> gradientStyles[STYLE_MAX];
|
||||
nsRefPtr<nsCanvasPatternAzure> patternStyles[STYLE_MAX];
|
||||
|
||||
nsString font;
|
||||
TextAlign textAlign;
|
||||
TextBaseline textBaseline;
|
||||
|
||||
nscolor colorStyles[STYLE_MAX];
|
||||
nscolor shadowColor;
|
||||
|
||||
mozilla::gfx::Matrix transform;
|
||||
mozilla::gfx::Point shadowOffset;
|
||||
mozilla::gfx::Float lineWidth;
|
||||
mozilla::gfx::Float miterLimit;
|
||||
mozilla::gfx::Float globalAlpha;
|
||||
mozilla::gfx::Float shadowBlur;
|
||||
FallibleTArray<mozilla::gfx::Float> dash;
|
||||
mozilla::gfx::Float dashOffset;
|
||||
|
||||
mozilla::gfx::CompositionOp op;
|
||||
mozilla::gfx::FillRule fillRule;
|
||||
mozilla::gfx::CapStyle lineCap;
|
||||
mozilla::gfx::JoinStyle lineJoin;
|
||||
|
||||
bool imageSmoothingEnabled;
|
||||
};
|
||||
|
||||
nsAutoTArray<ContextState, 3> mStyleStack;
|
||||
|
||||
inline ContextState& CurrentState() {
|
||||
return mStyleStack[mStyleStack.Length() - 1];
|
||||
}
|
||||
|
||||
friend class GeneralPattern;
|
||||
friend class AdjustedTarget;
|
||||
|
||||
// other helpers
|
||||
void GetAppUnitsValues(PRUint32 *perDevPixel, PRUint32 *perCSSPixel) {
|
||||
// If we don't have a canvas element, we just return something generic.
|
||||
PRUint32 devPixel = 60;
|
||||
PRUint32 cssPixel = 60;
|
||||
|
||||
nsIPresShell *ps = GetPresShell();
|
||||
nsPresContext *pc;
|
||||
|
||||
if (!ps) goto FINISH;
|
||||
pc = ps->GetPresContext();
|
||||
if (!pc) goto FINISH;
|
||||
devPixel = pc->AppUnitsPerDevPixel();
|
||||
cssPixel = pc->AppUnitsPerCSSPixel();
|
||||
|
||||
FINISH:
|
||||
if (perDevPixel)
|
||||
*perDevPixel = devPixel;
|
||||
if (perCSSPixel)
|
||||
*perCSSPixel = cssPixel;
|
||||
}
|
||||
|
||||
friend struct nsCanvasBidiProcessorAzure;
|
||||
};
|
||||
|
||||
#endif /* nsCanvasRenderingContext2DAzure_h */
|
|
@ -19548,11 +19548,7 @@ ok(window.CanvasRenderingContext2D.prototype, "window.CanvasRenderingContext2D.p
|
|||
window.CanvasRenderingContext2D.prototype.fill = 1;
|
||||
ok(window.CanvasRenderingContext2D.prototype.fill === 1, "window.CanvasRenderingContext2D.prototype.fill === 1");
|
||||
delete window.CanvasRenderingContext2D.prototype.fill;
|
||||
if (IsAzureEnabled()) {
|
||||
ok(window.CanvasRenderingContext2D.prototype.fill === undefined, "window.CanvasRenderingContext2D.prototype.fill === undefined");
|
||||
} else {
|
||||
todo(window.CanvasRenderingContext2D.prototype.fill === undefined, "window.CanvasRenderingContext2D.prototype.fill === undefined");
|
||||
}
|
||||
|
||||
//restore the original method to ensure that other tests can run successfully
|
||||
window.CanvasRenderingContext2D.prototype.fill = fill;
|
||||
|
|
|
@ -765,8 +765,12 @@ nsresult
|
|||
NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult)
|
||||
{
|
||||
Telemetry::Accumulate(Telemetry::CANVAS_2D_USED, 1);
|
||||
if (AzureCanvasEnabled()) {
|
||||
return NS_NewCanvasRenderingContext2DAzure(aResult);
|
||||
if (Preferences::GetBool("gfx.canvas.azure.enabled", false)) {
|
||||
nsresult rv = NS_NewCanvasRenderingContext2DAzure(aResult);
|
||||
// If Azure fails, fall back to a classic canvas.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_NewCanvasRenderingContext2DThebes(aResult);
|
||||
|
|
|
@ -534,7 +534,6 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
|
|||
|
||||
#undef None // something included above defines this preprocessor symbol, maybe Xlib headers
|
||||
#include "WebGLContext.h"
|
||||
#include "nsICanvasRenderingContextInternal.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -4591,10 +4590,6 @@ nsDOMClassInfo::Init()
|
|||
// Non-proxy bindings
|
||||
mozilla::dom::Register(nameSpaceManager);
|
||||
|
||||
if (!AzureCanvasEnabled()) {
|
||||
nameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING("CanvasRenderingContext2D"), NULL);
|
||||
}
|
||||
|
||||
sIsInitialized = true;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
|
||||
|
||||
#include "sampler.h"
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "xpcpublic.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
// nsGlobalWindow implements nsWrapperCache, but doesn't always use it. Don't
|
||||
// try to use it without fixing that first.
|
||||
|
@ -188,7 +187,7 @@ inline nsresult
|
|||
UnwrapObject(JSContext* cx, JSObject* obj, U& value)
|
||||
{
|
||||
return UnwrapObject<static_cast<prototypes::ID>(
|
||||
PrototypeIDMap<T>::PrototypeID), T>(cx, obj, value);
|
||||
PrototypeIDMap<T>::PrototypeID)>(cx, obj, value);
|
||||
}
|
||||
|
||||
const size_t kProtoOrIfaceCacheCount =
|
||||
|
|
|
@ -68,40 +68,6 @@ DOMInterfaces = {
|
|||
'castable': False
|
||||
}],
|
||||
|
||||
'CanvasRenderingContext2D': [
|
||||
{
|
||||
'nativeType': 'nsCanvasRenderingContext2DAzure',
|
||||
# Making this non-prefable requires that we ensure that nothing takes this
|
||||
# type as an argument or that the non-Azure variant is removed.
|
||||
'prefable': True,
|
||||
'infallible': {
|
||||
'all': [
|
||||
'canvas', 'save', 'restore', 'globalAlpha', 'shadowOffsetX',
|
||||
'shadowOffsetY', 'shadowBlur', 'shadowColor', 'clearRect',
|
||||
'fillRect', 'strokeRect', 'beginPath', 'fill', 'stroke', 'clip',
|
||||
'isPointInPath', 'lineWidth', 'lineCap', 'miterLimit', 'textAlign',
|
||||
'textBaseline', 'closePath', 'moveTo', 'lineTo', 'quadraticCurveTo',
|
||||
'bezierCurveTo', 'rect', 'mozFillRule', 'mozDashOffset',
|
||||
'mozImageSmoothingEnabled'
|
||||
],
|
||||
'setterOnly': [
|
||||
'strokeStyle', 'fillStyle', 'lineJoin'
|
||||
],
|
||||
'getterOnly': [
|
||||
'font', 'mozTextStyle'
|
||||
]
|
||||
},
|
||||
'implicitJSContext': [
|
||||
'createImageData', 'getImageData', 'putImageData', 'strokeStyle',
|
||||
'fillStyle', 'mozDash'
|
||||
],
|
||||
'resultNotAddRefed': [ 'canvas' ],
|
||||
'binaryNames': {
|
||||
'mozImageSmoothingEnabled': 'imageSmoothingEnabled',
|
||||
'mozFillRule': 'fillRule'
|
||||
}
|
||||
}],
|
||||
|
||||
'Document': [
|
||||
{
|
||||
'nativeType': 'nsIDocument',
|
||||
|
@ -391,11 +357,7 @@ def addExternalHTMLElement(element):
|
|||
addExternalHTMLElement('HTMLCanvasElement')
|
||||
addExternalHTMLElement('HTMLImageElement')
|
||||
addExternalHTMLElement('HTMLVideoElement')
|
||||
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
addExternalIface('ImageData', nativeType='mozilla::dom::ImageData')
|
||||
addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('WebGLActiveInfo', nativeType='mozilla::WebGLActiveInfo',
|
||||
headerFile='WebGLContext.h')
|
||||
addExternalIface('WebGLBuffer', nativeType='mozilla::WebGLBuffer',
|
||||
|
@ -417,5 +379,3 @@ addExternalIface('WebGLShaderPrecisionFormat',
|
|||
headerFile='WebGLContext.h')
|
||||
addExternalIface('WebGLTexture', nativeType='mozilla::WebGLTexture',
|
||||
headerFile='WebGLContext.h')
|
||||
addExternalIface('Window')
|
||||
addExternalIface('XULElement')
|
||||
|
|
|
@ -75,7 +75,6 @@ EXPORTS_$(binding_include_path) = \
|
|||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/js/xpconnect/src \
|
||||
-I$(topsrcdir)/js/xpconnect/wrappers \
|
||||
-I$(topsrcdir)/content/canvas/src \
|
||||
-I$(topsrcdir)/content/html/content/src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -46,9 +46,7 @@ interface nsIDOMCanvasRenderingContext2D : nsISupports
|
|||
readonly attribute nsIDOMHTMLCanvasElement canvas;
|
||||
|
||||
// state
|
||||
[binaryname(MozSave)]
|
||||
void save();
|
||||
[binaryname(MozRestore)]
|
||||
void restore();
|
||||
|
||||
// transformations
|
||||
|
@ -95,9 +93,7 @@ enum CanvasMultiGetterType {
|
|||
nsIDOMCanvasGradient createRadialGradient(in float x0, in float y0, in float r0, in float x1, in float y1, in float r1);
|
||||
nsIDOMCanvasPattern createPattern(in nsIDOMHTMLElement image, [Null(Stringify)] in DOMString repetition);
|
||||
attribute float lineWidth; /* default 1 */
|
||||
[binaryname(MozLineCap)]
|
||||
attribute DOMString lineCap; /* "butt", "round", "square" (default) */
|
||||
[binaryname(MozLineJoin)]
|
||||
attribute DOMString lineJoin; /* "round", "bevel", "miter" (default) */
|
||||
attribute float miterLimit; /* default 10 */
|
||||
|
||||
|
@ -109,7 +105,6 @@ enum CanvasMultiGetterType {
|
|||
attribute float shadowOffsetX;
|
||||
attribute float shadowOffsetY;
|
||||
attribute float shadowBlur;
|
||||
[binaryname(MozShadowColor)]
|
||||
attribute DOMString shadowColor;
|
||||
|
||||
// rects
|
||||
|
@ -118,9 +113,7 @@ enum CanvasMultiGetterType {
|
|||
void strokeRect(in float x, in float y, in float w, in float h);
|
||||
|
||||
// path API
|
||||
[binaryname(MozBeginPath)]
|
||||
void beginPath();
|
||||
[binaryname(MozClosePath)]
|
||||
void closePath();
|
||||
|
||||
void moveTo(in float x, in float y);
|
||||
|
@ -131,20 +124,14 @@ enum CanvasMultiGetterType {
|
|||
void arc(in float x, in float y, in float r, in float startAngle, in float endAngle, [optional] in boolean anticlockwise);
|
||||
void rect(in float x, in float y, in float w, in float h);
|
||||
|
||||
[binaryname(MozFill)]
|
||||
void fill();
|
||||
[binaryname(MozStroke)]
|
||||
void stroke();
|
||||
[binaryname(MozClip)]
|
||||
void clip();
|
||||
|
||||
// text api
|
||||
[binaryname(MozFont)]
|
||||
attribute DOMString font; /* default "10px sans-serif" */
|
||||
[binaryname(MozTextAlign)]
|
||||
attribute DOMString textAlign; /* "start" (default), "end", "left", "right",
|
||||
"center" */
|
||||
[binaryname(MozTextBaseline)]
|
||||
attribute DOMString textBaseline; /* "alphabetic" (default), "top", "hanging",
|
||||
"middle", "ideographic", "bottom" */
|
||||
|
||||
|
@ -152,7 +139,6 @@ enum CanvasMultiGetterType {
|
|||
void strokeText(in DOMString text, in float x, in float y, [optional] in float maxWidth);
|
||||
nsIDOMTextMetrics measureText(in DOMString text);
|
||||
|
||||
[binaryname(TextStyle)]
|
||||
attribute DOMString mozTextStyle;
|
||||
|
||||
// image api
|
||||
|
|
|
@ -1,210 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/
|
||||
*
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
interface CanvasGradient;
|
||||
interface CanvasPattern;
|
||||
interface HitRegionOptions;
|
||||
interface HTMLCanvasElement;
|
||||
interface HTMLImageElement;
|
||||
interface HTMLVideoElement;
|
||||
interface ImageData;
|
||||
interface TextMetrics;
|
||||
interface Window;
|
||||
interface XULElement;
|
||||
|
||||
interface CanvasRenderingContext2D {
|
||||
|
||||
// back-reference to the canvas
|
||||
readonly attribute HTMLCanvasElement canvas;
|
||||
|
||||
// state
|
||||
void save(); // push state on state stack
|
||||
void restore(); // pop state stack and restore state
|
||||
|
||||
// transformations (default transform is the identity matrix)
|
||||
// NOT IMPLEMENTED attribute SVGMatrix currentTransform;
|
||||
void scale(double x, double y);
|
||||
void rotate(double angle);
|
||||
void translate(double x, double y);
|
||||
void transform(double a, double b, double c, double d, double e, double f);
|
||||
void setTransform(double a, double b, double c, double d, double e, double f);
|
||||
// NOT IMPLEMENTED void resetTransform();
|
||||
|
||||
// compositing
|
||||
attribute double globalAlpha; // (default 1.0)
|
||||
attribute DOMString globalCompositeOperation; // (default source-over)
|
||||
|
||||
// colors and styles (see also the CanvasDrawingStyles interface)
|
||||
attribute any strokeStyle; // (default black)
|
||||
attribute any fillStyle; // (default black)
|
||||
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
|
||||
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
|
||||
CanvasPattern createPattern((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, DOMString repetition);
|
||||
|
||||
// shadows
|
||||
attribute double shadowOffsetX; // (default 0)
|
||||
attribute double shadowOffsetY; // (default 0)
|
||||
attribute double shadowBlur; // (default 0)
|
||||
attribute DOMString shadowColor; // (default transparent black)
|
||||
|
||||
// rects
|
||||
void clearRect(double x, double y, double w, double h);
|
||||
void fillRect(double x, double y, double w, double h);
|
||||
void strokeRect(double x, double y, double w, double h);
|
||||
|
||||
// path API (see also CanvasPathMethods)
|
||||
void beginPath();
|
||||
void fill();
|
||||
// NOT IMPLEMENTED void fill(Path path);
|
||||
void stroke();
|
||||
// NOT IMPLEMENTED void stroke(Path path);
|
||||
// NOT IMPLEMENTED void drawSystemFocusRing(Element element);
|
||||
// NOT IMPLEMENTED void drawSystemFocusRing(Path path, Element element);
|
||||
// NOT IMPLEMENTED boolean drawCustomFocusRing(Element element);
|
||||
// NOT IMPLEMENTED boolean drawCustomFocusRing(Path path, Element element);
|
||||
// NOT IMPLEMENTED void scrollPathIntoView();
|
||||
// NOT IMPLEMENTED void scrollPathIntoView(Path path);
|
||||
void clip();
|
||||
// NOT IMPLEMENTED void clip(Path path);
|
||||
// NOT IMPLEMENTED void resetClip();
|
||||
boolean isPointInPath(double x, double y);
|
||||
// NOT IMPLEMENTED boolean isPointInPath(Path path, double x, double y);
|
||||
|
||||
// text (see also the CanvasDrawingStyles interface)
|
||||
void fillText(DOMString text, double x, double y, optional double maxWidth);
|
||||
void strokeText(DOMString text, double x, double y, optional double maxWidth);
|
||||
TextMetrics measureText(DOMString text);
|
||||
|
||||
// drawing images
|
||||
// NOT IMPLEMENTED attribute boolean imageSmoothingEnabled; // (default true)
|
||||
void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, double dx, double dy);
|
||||
void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, double dx, double dy, double dw, double dh);
|
||||
void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh);
|
||||
|
||||
// hit regions
|
||||
// NOT IMPLEMENTED void addHitRegion(HitRegionOptions options);
|
||||
|
||||
// pixel manipulation
|
||||
[Creator] ImageData createImageData(double sw, double sh);
|
||||
[Creator] ImageData createImageData(ImageData imagedata);
|
||||
[Creator] ImageData getImageData(double sx, double sy, double sw, double sh);
|
||||
void putImageData(ImageData imagedata, double dx, double dy);
|
||||
void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
|
||||
|
||||
// Mozilla-specific stuff
|
||||
// FIXME Bug 768048 mozCurrentTransform/mozCurrentTransformInverse should return a WebIDL array.
|
||||
attribute object mozCurrentTransform; // [ m11, m12, m21, m22, dx, dy ], i.e. row major
|
||||
attribute object mozCurrentTransformInverse;
|
||||
attribute DOMString mozFillRule; /* "evenodd", "nonzero" (default) */
|
||||
attribute any mozDash; /* default |null| */
|
||||
attribute double mozDashOffset; /* default 0.0 */
|
||||
attribute DOMString mozTextStyle;
|
||||
|
||||
// image smoothing mode -- if disabled, images won't be smoothed
|
||||
// if scaled.
|
||||
attribute boolean mozImageSmoothingEnabled;
|
||||
|
||||
// Show the caret if appropriate when drawing
|
||||
const unsigned long DRAWWINDOW_DRAW_CARET = 0x01;
|
||||
// Don't flush pending layout notifications that could otherwise
|
||||
// be batched up
|
||||
const unsigned long DRAWWINDOW_DO_NOT_FLUSH = 0x02;
|
||||
// Draw scrollbars and scroll the viewport if they are present
|
||||
const unsigned long DRAWWINDOW_DRAW_VIEW = 0x04;
|
||||
// Use the widget layer manager if available. This means hardware
|
||||
// acceleration may be used, but it might actually be slower or
|
||||
// lower quality than normal. It will however more accurately reflect
|
||||
// the pixels rendered to the screen.
|
||||
const unsigned long DRAWWINDOW_USE_WIDGET_LAYERS = 0x08;
|
||||
// Don't synchronously decode images - draw what we have
|
||||
const unsigned long DRAWWINDOW_ASYNC_DECODE_IMAGES = 0x10;
|
||||
|
||||
/**
|
||||
* Renders a region of a window into the canvas. The contents of
|
||||
* the window's viewport are rendered, ignoring viewport clipping
|
||||
* and scrolling.
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param w
|
||||
* @param h specify the area of the window to render, in CSS
|
||||
* pixels.
|
||||
*
|
||||
* @param backgroundColor the canvas is filled with this color
|
||||
* before we render the window into it. This color may be
|
||||
* transparent/translucent. It is given as a CSS color string
|
||||
* (e.g., rgb() or rgba()).
|
||||
*
|
||||
* @param flags Used to better control the drawWindow call.
|
||||
* Flags can be ORed together.
|
||||
*
|
||||
* Of course, the rendering obeys the current scale, transform and
|
||||
* globalAlpha values.
|
||||
*
|
||||
* Hints:
|
||||
* -- If 'rgba(0,0,0,0)' is used for the background color, the
|
||||
* drawing will be transparent wherever the window is transparent.
|
||||
* -- Top-level browsed documents are usually not transparent
|
||||
* because the user's background-color preference is applied,
|
||||
* but IFRAMEs are transparent if the page doesn't set a background.
|
||||
* -- If an opaque color is used for the background color, rendering
|
||||
* will be faster because we won't have to compute the window's
|
||||
* transparency.
|
||||
*
|
||||
* This API cannot currently be used by Web content. It is chrome
|
||||
* only.
|
||||
* FIXME Bug 767931 - Mark drawWindow and asyncDrawXULElement as ChromeOnly
|
||||
* in WebIDL
|
||||
*/
|
||||
void drawWindow(Window window, double x, double y, double w, double h,
|
||||
DOMString bgColor, optional unsigned long flags = 0);
|
||||
void asyncDrawXULElement(XULElement elem, double x, double y, double w,
|
||||
double h, DOMString bgColor,
|
||||
optional unsigned long flags = 0);
|
||||
};
|
||||
CanvasRenderingContext2D implements CanvasDrawingStyles;
|
||||
CanvasRenderingContext2D implements CanvasPathMethods;
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface CanvasDrawingStyles {
|
||||
// line caps/joins
|
||||
attribute double lineWidth; // (default 1)
|
||||
attribute DOMString lineCap; // "butt", "round", "square" (default "butt")
|
||||
attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter")
|
||||
attribute double miterLimit; // (default 10)
|
||||
|
||||
// dashed lines
|
||||
// NOT IMPLEMENTED void setLineDash(sequence<double> segments); // default empty
|
||||
// NOT IMPLEMENTED sequence<double> getLineDash();
|
||||
// NOT IMPLEMENTED attribute double lineDashOffset;
|
||||
|
||||
// text
|
||||
attribute DOMString font; // (default 10px sans-serif)
|
||||
attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
|
||||
attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface CanvasPathMethods {
|
||||
// shared path API methods
|
||||
void closePath();
|
||||
void moveTo(double x, double y);
|
||||
void lineTo(double x, double y);
|
||||
void quadraticCurveTo(double cpx, double cpy, double x, double y);
|
||||
void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
|
||||
void arcTo(double x1, double y1, double x2, double y2, double radius);
|
||||
// NOT IMPLEMENTED void arcTo(double x1, double y1, double x2, double y2, double radiusX, double radiusY, double rotation);
|
||||
void rect(double x, double y, double w, double h);
|
||||
void arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise = false);
|
||||
// NOT IMPLEMENTED void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, boolean anticlockwise);
|
||||
};
|
|
@ -5,7 +5,6 @@
|
|||
webidl_base = $(topsrcdir)/dom/webidl
|
||||
|
||||
webidl_files = \
|
||||
CanvasRenderingContext2D.webidl \
|
||||
Function.webidl \
|
||||
EventListener.webidl \
|
||||
EventTarget.webidl \
|
||||
|
|
Загрузка…
Ссылка в новой задаче