Changeset 64407 in webkit


Ignore:
Timestamp:
Jul 30, 2010 10:08:15 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-07-30 Matthew Delaney <mdelaney@apple.com>

Reviewed by Darin Adler.

ctx.clearRect improperly clears shadow
https://bugs.webkit.org/show_bug.cgi?id=43213

  • canvas/philip/tests/2d.clearRect+fillRect.alpha0-expected.txt: Added.
  • canvas/philip/tests/2d.clearRect+fillRect.alpha0.5-expected.txt: Added.
  • canvas/philip/tests/2d.clearRect+fillRect.alpha0.5.html: Added. Same as above but with alpha of one half.
  • canvas/philip/tests/2d.clearRect+fillRect.alpha0.html: Added. Tests that clearing rect with alpha or 0 has no unwanted side-effects
  • canvas/philip/tests/2d.clearRect+fillRect.basic-expected.txt: Added.
  • canvas/philip/tests/2d.clearRect+fillRect.basic.html: Added. Tests clearing a rect and then filling back over doesn't show any side effects (such as caused by not ignoring/restoring appropriate context attributes).
  • platform/mac/Skipped: unskipping now passing test

2010-07-30 Matthew Delaney <mdelaney@apple.com>

Reviewed by Darin Adler.

ctx.clearRect improperly clears shadow
https://bugs.webkit.org/show_bug.cgi?id=43213

Tests: canvas/philip/tests/2d.clearRect+fillRect.alpha0.5.html

canvas/philip/tests/2d.clearRect+fillRect.alpha0.html
canvas/philip/tests/2d.clearRect+fillRect.basic.html

  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::setAllAttributesToDefault): Added a new method to wipe out all context attributes to their defaults. (WebCore::CanvasRenderingContext2D::clearRect): Updated clearRect to ignore shadow, alpha, and global composite attributes when clearing the input rect to match the canvas spec.
  • html/canvas/CanvasRenderingContext2D.h:
Location:
trunk
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64405 r64407  
     12010-07-30  Matthew Delaney  <mdelaney@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        ctx.clearRect improperly clears shadow
     6        https://bugs.webkit.org/show_bug.cgi?id=43213
     7
     8        * canvas/philip/tests/2d.clearRect+fillRect.alpha0-expected.txt: Added.
     9        * canvas/philip/tests/2d.clearRect+fillRect.alpha0.5-expected.txt: Added.
     10        * canvas/philip/tests/2d.clearRect+fillRect.alpha0.5.html: Added.
     11        Same as above but with alpha of one half.
     12        * canvas/philip/tests/2d.clearRect+fillRect.alpha0.html: Added.
     13        Tests that clearing rect with alpha or 0 has no unwanted side-effects
     14        * canvas/philip/tests/2d.clearRect+fillRect.basic-expected.txt: Added.
     15        * canvas/philip/tests/2d.clearRect+fillRect.basic.html: Added.
     16        Tests clearing a rect and then filling back over doesn't show any
     17        side effects (such as caused by not ignoring/restoring appropriate
     18        context attributes).
     19        * platform/mac/Skipped: unskipping now passing test
     20
    1212010-07-30  Luiz Agostini  <luiz.agostini@openbossa.org>
    222
  • trunk/LayoutTests/platform/mac/Skipped

    r64401 r64407  
    166166canvas/philip/tests/2d.drawImage.broken.html
    167167canvas/philip/tests/2d.path.clip.empty.html
    168 canvas/philip/tests/2d.clearRect.shadow.html
    169168canvas/philip/tests/2d.composite.operation.clear.html
    170169canvas/philip/tests/2d.composite.operation.darker.html
  • trunk/WebCore/ChangeLog

    r64406 r64407  
     12010-07-30  Matthew Delaney  <mdelaney@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        ctx.clearRect improperly clears shadow
     6        https://bugs.webkit.org/show_bug.cgi?id=43213
     7
     8        Tests: canvas/philip/tests/2d.clearRect+fillRect.alpha0.5.html
     9               canvas/philip/tests/2d.clearRect+fillRect.alpha0.html
     10               canvas/philip/tests/2d.clearRect+fillRect.basic.html
     11
     12        * html/canvas/CanvasRenderingContext2D.cpp:
     13        (WebCore::CanvasRenderingContext2D::setAllAttributesToDefault):
     14        Added a new method to wipe out all context attributes to their defaults.
     15        (WebCore::CanvasRenderingContext2D::clearRect):
     16        Updated clearRect to ignore shadow, alpha, and global composite attributes
     17        when clearing the input rect to match the canvas spec.
     18        * html/canvas/CanvasRenderingContext2D.h:
     19
    1202010-07-30  Kinuko Yasuda  <kinuko@chromium.org>
    221
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r64004 r64407  
    165165}
    166166
     167void CanvasRenderingContext2D::setAllAttributesToDefault()
     168{
     169    state().m_globalAlpha = 1;
     170    state().m_shadowOffset = FloatSize();
     171    state().m_shadowBlur = 0;
     172    state().m_shadowColor = Color::transparent;
     173    state().m_globalComposite = CompositeSourceOver;
     174
     175    GraphicsContext* context = drawingContext();
     176    if (!context)
     177        return;
     178
     179    context->setShadow(FloatSize(), 0, Color::transparent, DeviceColorSpace);
     180    context->setAlpha(1);
     181    context->setCompositeOperation(CompositeSourceOver);
     182}
     183
    167184CanvasStyle* CanvasRenderingContext2D::strokeStyle() const
    168185{
     
    791808    if (!validateRectForCanvas(x, y, width, height))
    792809        return;
    793     GraphicsContext* c = drawingContext();
    794     if (!c)
     810    GraphicsContext* context = drawingContext();
     811    if (!context)
    795812        return;
    796813    if (!state().m_invertibleCTM)
    797814        return;
    798815    FloatRect rect(x, y, width, height);
     816
     817    save();
     818    setAllAttributesToDefault();
    799819    willDraw(rect);
    800     c->clearRect(rect);
     820    context->clearRect(rect);
     821    restore();
    801822}
    802823
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.h

    r64004 r64407  
    105105    void save();
    106106    void restore();
     107    void setAllAttributesToDefault();
    107108
    108109    void scale(float sx, float sy);
Note: See TracChangeset for help on using the changeset viewer.