зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1205900 - Compare context and canvas element sizes before extracting the data. r=gwright
This commit is contained in:
Родитель
36ac94db5d
Коммит
d781f5c2bd
|
@ -1472,7 +1472,6 @@ CanvasRenderingContext2D::EnsureTarget(RenderingMode aRenderingMode)
|
|||
return mode;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
int32_t
|
||||
CanvasRenderingContext2D::GetWidth() const
|
||||
{
|
||||
|
@ -1484,7 +1483,6 @@ CanvasRenderingContext2D::GetHeight() const
|
|||
{
|
||||
return mHeight;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
CanvasRenderingContext2D::SetDimensions(int32_t width, int32_t height)
|
||||
|
|
|
@ -418,10 +418,9 @@ public:
|
|||
|
||||
nsresult Redraw();
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual int32_t GetWidth() const override;
|
||||
virtual int32_t GetHeight() const override;
|
||||
#endif
|
||||
virtual int32_t GetWidth() const override;
|
||||
virtual int32_t GetHeight() const override;
|
||||
|
||||
// nsICanvasRenderingContextInternal
|
||||
/**
|
||||
* Gets the pres shell from either the canvas element or the doc shell
|
||||
|
|
|
@ -480,7 +480,6 @@ WebGLContext::SetContextOptions(JSContext* cx, JS::Handle<JS::Value> options)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
int32_t
|
||||
WebGLContext::GetWidth() const
|
||||
{
|
||||
|
@ -492,7 +491,6 @@ WebGLContext::GetHeight() const
|
|||
{
|
||||
return mHeight;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* So there are a number of points of failure here. We might fail based
|
||||
* on EGL vs. WGL, or we might fail to alloc a too-large size, or we
|
||||
|
|
|
@ -215,10 +215,9 @@ public:
|
|||
NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT
|
||||
|
||||
// nsICanvasRenderingContextInternal
|
||||
#ifdef DEBUG
|
||||
virtual int32_t GetWidth() const override;
|
||||
virtual int32_t GetHeight() const override;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD SetDimensions(int32_t width, int32_t height) override;
|
||||
NS_IMETHOD InitializeWithSurface(nsIDocShell*, gfxASurface*, int32_t,
|
||||
int32_t) override
|
||||
|
|
|
@ -80,11 +80,9 @@ public:
|
|||
return mCanvasElement;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// Useful for testing
|
||||
virtual int32_t GetWidth() const = 0;
|
||||
virtual int32_t GetHeight() const = 0;
|
||||
#endif
|
||||
// Dimensions of the canvas, in pixels.
|
||||
virtual int32_t GetWidth() const = 0;
|
||||
virtual int32_t GetHeight() const = 0;
|
||||
|
||||
// Sets the dimensions of the canvas, in pixels. Called
|
||||
// whenever the size of the element changes.
|
||||
|
|
|
@ -669,18 +669,19 @@ HTMLCanvasElement::ToBlob(JSContext* aCx,
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mCurrentContext) {
|
||||
// We disallow canvases of width or height zero, and set them to 1, so
|
||||
// we will have a discrepancy with the sizes of the canvas and the context.
|
||||
// That discrepancy is OK, the rest are not.
|
||||
nsIntSize elementSize = GetWidthHeight();
|
||||
MOZ_ASSERT(elementSize.width == mCurrentContext->GetWidth() ||
|
||||
(elementSize.width == 0 && mCurrentContext->GetWidth() == 1));
|
||||
MOZ_ASSERT(elementSize.height == mCurrentContext->GetHeight() ||
|
||||
(elementSize.height == 0 && mCurrentContext->GetHeight() == 1));
|
||||
if ((elementSize.width != mCurrentContext->GetWidth() &&
|
||||
(elementSize.width != 0 || mCurrentContext->GetWidth() != 1)) ||
|
||||
(elementSize.height != mCurrentContext->GetHeight() &&
|
||||
(elementSize.height != 0 || mCurrentContext->GetHeight() != 1))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t* imageBuffer = nullptr;
|
||||
int32_t format = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче