Changeset 84631 in webkit


Ignore:
Timestamp:
Apr 22, 2011 8:51:24 AM (13 years ago)
Author:
Simon Fraser
Message:

2011-04-21 Simon Fraser <Simon Fraser>

Reviewed by Dan Bernstein.

Extra GraphicsContext::save() in InlineTextBox::paintDecoration()
https://bugs.webkit.org/show_bug.cgi?id=59109

Remove an extraneous GraphicsContext::save() in InlineTextBox::paintDecoration().

Add an assertion that fires when a GraphicsContext() is destroyed with a non-
empty state stack. Fix canvas to avoid this assertion, since bad content might
trigger it.

Also add an assertion that fires for mismatched begin/endTransparencyLayers.

Test: fast/text/multiple-text-shadow-alpha.html

  • html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::~HTMLCanvasElement): Make sure that the CanvasRenderingContext goes away before the ImageBuffer, so that CanvasRenderingContext2D has a chance to unwind the state stack in the ImageBuffer's GraphicsContext.
  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D): Balance unmatched state saves in the canvas context.
  • platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::~GraphicsContext): Assert that the stack is empty.
  • platform/graphics/cg/GraphicsContextPlatformPrivateCG.h: (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate): (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate): (WebCore::GraphicsContextPlatformPrivate::beginTransparencyLayer): (WebCore::GraphicsContextPlatformPrivate::endTransparencyLayer): Changes to allow for asserting for unmatched transparency layer begin/ends.
  • rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::paintDecoration): Remove an unbalanced save().
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84630 r84631  
     12011-04-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Extra GraphicsContext::save() in InlineTextBox::paintDecoration()
     6        https://bugs.webkit.org/show_bug.cgi?id=59109
     7       
     8        Testcase that exercises the fixed InlineTextBox::paintDecoration() code.
     9
     10        * fast/text/multiple-text-shadow-alpha-expected.txt: Added.
     11        * fast/text/multiple-text-shadow-alpha.html: Added.
     12
    1132011-04-22  Jessie Berlin  <jberlin@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r84629 r84631  
     12011-04-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Extra GraphicsContext::save() in InlineTextBox::paintDecoration()
     6        https://bugs.webkit.org/show_bug.cgi?id=59109
     7       
     8        Remove an extraneous GraphicsContext::save() in InlineTextBox::paintDecoration().
     9       
     10        Add an assertion that fires when a GraphicsContext() is destroyed with a non-
     11        empty state stack. Fix canvas to avoid this assertion, since bad content might
     12        trigger it.
     13       
     14        Also add an assertion that fires for mismatched begin/endTransparencyLayers.
     15
     16        Test: fast/text/multiple-text-shadow-alpha.html
     17
     18        * html/HTMLCanvasElement.cpp:
     19        (WebCore::HTMLCanvasElement::~HTMLCanvasElement):
     20        Make sure that the CanvasRenderingContext goes away before the ImageBuffer,
     21        so that CanvasRenderingContext2D has a chance to unwind the state stack in
     22        the ImageBuffer's GraphicsContext.
     23       
     24        * html/canvas/CanvasRenderingContext2D.cpp:
     25        (WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D):
     26        Balance unmatched state saves in the canvas context.
     27       
     28        * platform/graphics/GraphicsContext.cpp:
     29        (WebCore::GraphicsContext::~GraphicsContext):
     30        Assert that the stack is empty.
     31       
     32        * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
     33        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
     34        (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
     35        (WebCore::GraphicsContextPlatformPrivate::beginTransparencyLayer):
     36        (WebCore::GraphicsContextPlatformPrivate::endTransparencyLayer):
     37        Changes to allow for asserting for unmatched transparency layer begin/ends.
     38       
     39        * rendering/InlineTextBox.cpp:
     40        (WebCore::InlineTextBox::paintDecoration):
     41        Remove an unbalanced save().
     42
    1432011-04-22  Pavel Feldman  <pfeldman@google.com>
    244
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r84101 r84631  
    102102    for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it)
    103103        (*it)->canvasDestroyed(this);
     104
     105    m_context.clear(); // Ensure this goes away before the ImageBuffer.
    104106}
    105107
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r84512 r84631  
    146146CanvasRenderingContext2D::~CanvasRenderingContext2D()
    147147{
     148#if !ASSERT_DISABLED
     149    // Ensure that the state stack in the ImageBuffer's context
     150    // is cleared before destruction, to avoid assertions in the
     151    // GraphicsContext dtor.
     152    if (size_t stackSize = m_stateStack.size()) {
     153        if (GraphicsContext* context = drawingContext()) {
     154            while (--stackSize)
     155                context->restore();
     156        }
     157    }
     158#endif
    148159}
    149160
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r84273 r84631  
    8585GraphicsContext::~GraphicsContext()
    8686{
     87    ASSERT(m_stack.isEmpty());
    8788    platformDestroy();
    8889}
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h

    r81161 r84631  
    4545#if PLATFORM(WIN)
    4646        , m_hdc(0)
     47        , m_shouldIncludeChildWindows(false)
     48#endif
     49#if PLATFORM(WIN) || !ASSERT_DISABLED
    4750        , m_transparencyCount(0)
    48         , m_shouldIncludeChildWindows(false)
    4951#endif
    5052        , m_userToDeviceTransformKnownToBeIdentity(false)
     
    5557    ~GraphicsContextPlatformPrivate()
    5658    {
     59        ASSERT(!m_transparencyCount);
    5760    }
    5861
     
    6972    void concatCTM(const AffineTransform&) {}
    7073    void setCTM(const AffineTransform&) {}
    71     void beginTransparencyLayer() {}
    72     void endTransparencyLayer() {}
    7374#endif
    7475
     
    8586    void concatCTM(const AffineTransform&);
    8687    void setCTM(const AffineTransform&);
    87     void beginTransparencyLayer() { m_transparencyCount++; }
    88     void endTransparencyLayer() { m_transparencyCount--; }
    8988
    9089    HDC m_hdc;
    91     unsigned m_transparencyCount;
    9290    bool m_shouldIncludeChildWindows;
    9391#endif
    9492
     93    void beginTransparencyLayer()
     94    {
     95#if PLATFORM(WIN) || !ASSERT_DISABLED
     96        m_transparencyCount++;
     97#endif
     98    }
     99    void endTransparencyLayer()
     100    {
     101#if PLATFORM(WIN) || !ASSERT_DISABLED
     102        ASSERT(m_transparencyCount > 0);
     103        m_transparencyCount--;
     104#endif
     105    }
     106
    95107    RetainPtr<CGContextRef> m_cgContext;
     108#if PLATFORM(WIN) || !ASSERT_DISABLED
     109    int m_transparencyCount;
     110#endif
    96111    bool m_userToDeviceTransformKnownToBeIdentity;
    97112    GraphicsContextCGFlags m_contextFlags;
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r84504 r84631  
    896896    int extraOffset = 0;
    897897    if (!linesAreOpaque && shadow && shadow->next()) {
    898         context->save(); // FIXME: where is the balancing restore()?
    899898        FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2));
    900899        for (const ShadowData* s = shadow; s; s = s->next()) {
Note: See TracChangeset for help on using the changeset viewer.