- Revision
- 93901
- Author
- [email protected]
- Date
- 2011-08-26 12:11:59 -0700 (Fri, 26 Aug 2011)
Log Message
Assertion fires if canvas is resized while save() active
https://bugs.webkit.org/show_bug.cgi?id=66710
Reviewed by Simon Fraser.
Source/WebCore:
Test: fast/canvas/resize-while-save-active.html
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::reset):
Call CanvasRenderingContext2D::reset() before resizing the canvas,
so that the GraphicsContext state stack can be unwound.
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::unwindStateStack):
(WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D):
Refactor the state stack unwinding code from the destructor to
unwindStateStack() (new).
(WebCore::CanvasRenderingContext2D::reset):
Unwind the GraphicsContext state stack when the context is reset.
* html/canvas/CanvasRenderingContext2D.h:
LayoutTests:
* fast/canvas/resize-while-save-active-expected.txt: Added.
* fast/canvas/resize-while-save-active.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (93900 => 93901)
--- trunk/LayoutTests/ChangeLog 2011-08-26 18:59:54 UTC (rev 93900)
+++ trunk/LayoutTests/ChangeLog 2011-08-26 19:11:59 UTC (rev 93901)
@@ -1,3 +1,13 @@
+2011-08-23 Stephen White <[email protected]>
+
+ Assertion fires if canvas is resized while save() active
+ https://bugs.webkit.org/show_bug.cgi?id=66710
+
+ Reviewed by Simon Fraser.
+
+ * fast/canvas/resize-while-save-active-expected.txt: Added.
+ * fast/canvas/resize-while-save-active.html: Added.
+
2011-08-26 Martin Robinson <[email protected]>
Add some new baselines for GTK+ and unskip tests that now have them.
Added: trunk/LayoutTests/fast/canvas/resize-while-save-active-expected.txt (0 => 93901)
--- trunk/LayoutTests/fast/canvas/resize-while-save-active-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/resize-while-save-active-expected.txt 2011-08-26 19:11:59 UTC (rev 93901)
@@ -0,0 +1 @@
+If we got this far without an assertion, this test passed.
Added: trunk/LayoutTests/fast/canvas/resize-while-save-active.html (0 => 93901)
--- trunk/LayoutTests/fast/canvas/resize-while-save-active.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/resize-while-save-active.html 2011-08-26 19:11:59 UTC (rev 93901)
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+</head>
+<body>
+<canvas id="mycanvas" width="512" height="512"></canvas>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText()
+var canvas = document.getElementById('mycanvas');
+var ctx = canvas.getContext('2d');
+ctx.fillStyle = "rgb(255,165,0)";
+ctx.fillRect(0, 0, 512, 512);
+ctx.save();
+canvas.width = 256;
+ctx.fillStyle = "rgb(255,165,0)";
+ctx.fillRect(0, 0, 256, 512);
+document.body.appendChild(document.createElement("p")).appendChild(document.createTextNode("If we got this far without an assertion, this test passed."));
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (93900 => 93901)
--- trunk/Source/WebCore/ChangeLog 2011-08-26 18:59:54 UTC (rev 93900)
+++ trunk/Source/WebCore/ChangeLog 2011-08-26 19:11:59 UTC (rev 93901)
@@ -1,3 +1,25 @@
+2011-08-23 Stephen White <[email protected]>
+
+ Assertion fires if canvas is resized while save() active
+ https://bugs.webkit.org/show_bug.cgi?id=66710
+
+ Reviewed by Simon Fraser.
+
+ Test: fast/canvas/resize-while-save-active.html
+
+ * html/HTMLCanvasElement.cpp:
+ (WebCore::HTMLCanvasElement::reset):
+ Call CanvasRenderingContext2D::reset() before resizing the canvas,
+ so that the GraphicsContext state stack can be unwound.
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::unwindStateStack):
+ (WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D):
+ Refactor the state stack unwinding code from the destructor to
+ unwindStateStack() (new).
+ (WebCore::CanvasRenderingContext2D::reset):
+ Unwind the GraphicsContext state stack when the context is reset.
+ * html/canvas/CanvasRenderingContext2D.h:
+
2011-08-26 Darin Adler <[email protected]>
[Mac] Use the progress cursor instead of the wristwatch for CSS "wait" cursor
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (93900 => 93901)
--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2011-08-26 18:59:54 UTC (rev 93900)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2011-08-26 19:11:59 UTC (rev 93901)
@@ -237,6 +237,11 @@
if (!ok || h < 0)
h = DefaultHeight;
+ if (m_context && m_context->is2d()) {
+ CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get());
+ context2D->reset();
+ }
+
IntSize oldSize = size();
setSurfaceSize(IntSize(w, h)); // The image buffer gets cleared here.
@@ -245,11 +250,6 @@
static_cast<WebGLRenderingContext*>(m_context.get())->reshape(width(), height());
#endif
- if (m_context && m_context->is2d()) {
- CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get());
- context2D->reset();
- }
-
if (RenderObject* renderer = this->renderer()) {
if (m_rendererIsCanvas) {
if (oldSize != size())
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (93900 => 93901)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2011-08-26 18:59:54 UTC (rev 93900)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2011-08-26 19:11:59 UTC (rev 93901)
@@ -127,9 +127,8 @@
setLineWidth(lineWidth());
}
-CanvasRenderingContext2D::~CanvasRenderingContext2D()
+void CanvasRenderingContext2D::unwindStateStack()
{
-#if !ASSERT_DISABLED
// Ensure that the state stack in the ImageBuffer's context
// is cleared before destruction, to avoid assertions in the
// GraphicsContext dtor.
@@ -139,6 +138,12 @@
context->restore();
}
}
+}
+
+CanvasRenderingContext2D::~CanvasRenderingContext2D()
+{
+#if !ASSERT_DISABLED
+ unwindStateStack();
#endif
}
@@ -170,6 +175,7 @@
void CanvasRenderingContext2D::reset()
{
+ unwindStateStack();
m_stateStack.resize(1);
m_stateStack.first() = State();
m_path.clear();
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (93900 => 93901)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2011-08-26 18:59:54 UTC (rev 93900)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2011-08-26 19:11:59 UTC (rev 93901)
@@ -273,6 +273,8 @@
GraphicsContext* drawingContext() const;
+ void unwindStateStack();
+
void applyStrokePattern();
void applyFillPattern();