Changeset 93901 in webkit


Ignore:
Timestamp:
Aug 26, 2011, 12:11:59 PM (14 years ago)
Author:
senorblanco@chromium.org
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.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93898 r93901  
     12011-08-23  Stephen White  <senorblanco@chromium.org>
     2
     3        Assertion fires if canvas is resized while save() active
     4        https://bugs.webkit.org/show_bug.cgi?id=66710
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/canvas/resize-while-save-active-expected.txt: Added.
     9        * fast/canvas/resize-while-save-active.html: Added.
     10
    1112011-08-26  Martin Robinson  <mrobinson@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r93900 r93901  
     12011-08-23  Stephen White  <senorblanco@chromium.org>
     2
     3        Assertion fires if canvas is resized while save() active
     4        https://bugs.webkit.org/show_bug.cgi?id=66710
     5
     6        Reviewed by Simon Fraser.
     7
     8        Test: fast/canvas/resize-while-save-active.html
     9
     10        * html/HTMLCanvasElement.cpp:
     11        (WebCore::HTMLCanvasElement::reset):
     12        Call CanvasRenderingContext2D::reset() before resizing the canvas,
     13        so that the GraphicsContext state stack can be unwound.
     14        * html/canvas/CanvasRenderingContext2D.cpp:
     15        (WebCore::CanvasRenderingContext2D::unwindStateStack):
     16        (WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D):
     17        Refactor the state stack unwinding code from the destructor to
     18        unwindStateStack() (new).
     19        (WebCore::CanvasRenderingContext2D::reset):
     20        Unwind the GraphicsContext state stack when the context is reset.
     21        * html/canvas/CanvasRenderingContext2D.h:
     22
    1232011-08-26  Darin Adler  <darin@apple.com>
    224
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r93303 r93901  
    238238        h = DefaultHeight;
    239239
     240    if (m_context && m_context->is2d()) {
     241        CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get());
     242        context2D->reset();
     243    }
     244
    240245    IntSize oldSize = size();
    241246    setSurfaceSize(IntSize(w, h)); // The image buffer gets cleared here.
     
    245250        static_cast<WebGLRenderingContext*>(m_context.get())->reshape(width(), height());
    246251#endif
    247 
    248     if (m_context && m_context->is2d()) {
    249         CanvasRenderingContext2D* context2D = static_cast<CanvasRenderingContext2D*>(m_context.get());
    250         context2D->reset();
    251     }
    252252
    253253    if (RenderObject* renderer = this->renderer()) {
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r93873 r93901  
    128128}
    129129
    130 CanvasRenderingContext2D::~CanvasRenderingContext2D()
    131 {
    132 #if !ASSERT_DISABLED
     130void CanvasRenderingContext2D::unwindStateStack()
     131{
    133132    // Ensure that the state stack in the ImageBuffer's context
    134133    // is cleared before destruction, to avoid assertions in the
     
    140139        }
    141140    }
     141}
     142
     143CanvasRenderingContext2D::~CanvasRenderingContext2D()
     144{
     145#if !ASSERT_DISABLED
     146    unwindStateStack();
    142147#endif
    143148}
     
    171176void CanvasRenderingContext2D::reset()
    172177{
     178    unwindStateStack();
    173179    m_stateStack.resize(1);
    174180    m_stateStack.first() = State();
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h

    r93275 r93901  
    274274    GraphicsContext* drawingContext() const;
    275275
     276    void unwindStateStack();
     277
    276278    void applyStrokePattern();
    277279    void applyFillPattern();
Note: See TracChangeset for help on using the changeset viewer.