diff options
author | Pale Moon <git-repo@palemoon.org> | 2018-07-01 14:20:57 +0200 |
---|---|---|
committer | Pale Moon <git-repo@palemoon.org> | 2018-07-01 14:20:57 +0200 |
commit | 1abb23fdfaef17697209632b410a5432f72a71ed (patch) | |
tree | 9e4c574c09792b515425c40a0f138716392825cd | |
parent | f929ffa0e3f379de95a5e074e4058ce3fd6aabfb (diff) | |
download | palemoon-gre-1abb23fdfaef17697209632b410a5432f72a71ed.tar.gz |
Update dimensions early in ClearTarget.
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.cpp | 14 | ||||
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.h | 5 |
2 files changed, 13 insertions, 6 deletions
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 1b44c8289..8c202f26b 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -1435,8 +1435,6 @@ CanvasRenderingContext2D::GetHeight() const NS_IMETHODIMP CanvasRenderingContext2D::SetDimensions(int32_t width, int32_t height) { - ClearTarget(); - // Zero sized surfaces can cause problems. mZero = false; if (height == 0) { @@ -1447,14 +1445,14 @@ CanvasRenderingContext2D::SetDimensions(int32_t width, int32_t height) width = 1; mZero = true; } - mWidth = width; - mHeight = height; + ClearTarget(width, height); + return NS_OK; } void -CanvasRenderingContext2D::ClearTarget() +CanvasRenderingContext2D::ClearTarget(int32_t aWidth, int32_t aHeight) { Reset(); @@ -1473,6 +1471,12 @@ CanvasRenderingContext2D::ClearTarget() state->colorStyles[Style::STROKE] = NS_RGB(0,0,0); state->shadowColor = NS_RGBA(0,0,0,0); + // Update dimensions only if new (strictly positive) values were passed. + if (aWidth > 0 && aHeight > 0) { + mWidth = aWidth; + mHeight = aHeight; + } + // For vertical writing-mode, unless text-orientation is sideways, // we'll modify the initial value of textBaseline to 'middle'. nsRefPtr<nsStyleContext> canvasStyle; diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index 512c21289..2f0f515cb 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -704,8 +704,11 @@ protected: /** * Disposes an old target and prepares to lazily create a new target. + * + * Parameters are the new dimensions to be used. + * if either is negative or undefined, dimensions will remain unchanged. */ - void ClearTarget(); + void ClearTarget(int32_t aWidth = -1, int32_t aHeight = -1); /** * Check if the target is valid after calling EnsureTarget. |