diff options
author | Jonathan Kew <jkew@mozilla.com> | 2018-05-23 11:57:42 -0700 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-06-07 06:12:01 +0200 |
commit | 01e813736810d4afade739af76893f2d9ff1f93a (patch) | |
tree | a5251fbf7b55e1e8076eb4ab24fca67527454624 /dom/canvas/CanvasRenderingContext2D.cpp | |
parent | f35bf8b65d25f88c7e34263337b05619a78868f6 (diff) | |
download | UXP-01e813736810d4afade739af76893f2d9ff1f93a.tar UXP-01e813736810d4afade739af76893f2d9ff1f93a.tar.gz UXP-01e813736810d4afade739af76893f2d9ff1f93a.tar.lz UXP-01e813736810d4afade739af76893f2d9ff1f93a.tar.xz UXP-01e813736810d4afade739af76893f2d9ff1f93a.zip |
Update dimensions early in ClearTarget.
Diffstat (limited to 'dom/canvas/CanvasRenderingContext2D.cpp')
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index f4c4259f6..18af28e9f 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -1862,8 +1862,6 @@ CanvasRenderingContext2D::GetHeight() const NS_IMETHODIMP CanvasRenderingContext2D::SetDimensions(int32_t aWidth, int32_t aHeight) { - ClearTarget(); - // Zero sized surfaces can cause problems. mZero = false; if (aHeight == 0) { @@ -1874,14 +1872,14 @@ CanvasRenderingContext2D::SetDimensions(int32_t aWidth, int32_t aHeight) aWidth = 1; mZero = true; } - mWidth = aWidth; - mHeight = aHeight; + + ClearTarget(aWidth, aHeight); return NS_OK; } void -CanvasRenderingContext2D::ClearTarget() +CanvasRenderingContext2D::ClearTarget(int32_t aWidth, int32_t aHeight) { Reset(); @@ -1889,6 +1887,12 @@ CanvasRenderingContext2D::ClearTarget() SetInitialState(); + // 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'. RefPtr<nsStyleContext> canvasStyle; |