Changeset 58381 in webkit


Ignore:
Timestamp:
Apr 27, 2010 10:42:51 PM (14 years ago)
Author:
dbates@webkit.org
Message:

2010-04-27 Daniel Bates <dbates@rim.com>

Reviewed by Oliver Hunt.

https://bugs.webkit.org/show_bug.cgi?id=37686

Fixes an issue where the canvas method strokeRect will stroke a
rectangle whose dimensions are 0 when lineWidth > 1.

As per the definition of strokeRect in the HTML Canvas 2D Context
spec. <http://www.w3.org/TR/2dcontext/#dom-context-2d-strokerect>,
this method should have no effect when both the height and width
are zero.

Tests: fast/canvas/canvas-clearRect.html

fast/canvas/canvas-fillRect.html

  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::validateRectForCanvas): Return false if height, width == 0.

2010-04-27 Daniel Bates <dbates@rim.com>

Reviewed by Oliver Hunt.

https://bugs.webkit.org/show_bug.cgi?id=37686

Tests that strokeRect does not paint any artifacts when the
specified rectangle has height, width = 0 and lineWidth > 1.

Also tests that clearRect, fillRect, and rect are ignored when
height, width = 0.

  • fast/canvas/canvas-clearRect-expected.txt: Added.
  • fast/canvas/canvas-clearRect.html: Added.
  • fast/canvas/canvas-fillRect-expected.txt: Added.
  • fast/canvas/canvas-fillRect.html: Added.
  • fast/canvas/canvas-modify-emptyPath-expected.txt:
  • fast/canvas/canvas-strokeRect-expected.txt: Updated results.
  • fast/canvas/script-tests/canvas-clearRect.js: Added.
  • fast/canvas/script-tests/canvas-fillRect.js: Added.
  • fast/canvas/script-tests/canvas-modify-emptyPath.js: Added test case.
  • fast/canvas/script-tests/canvas-strokeRect.js: Ditto. Also, added debug statements so as to distinguish the results for each test.
Location:
trunk
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r58375 r58381  
     12010-04-27  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=37686
     6
     7        Tests that strokeRect does not paint any artifacts when the
     8        specified rectangle has height, width = 0 and lineWidth > 1.
     9
     10        Also tests that clearRect, fillRect, and rect are ignored when
     11        height, width = 0.
     12
     13        * fast/canvas/canvas-clearRect-expected.txt: Added.
     14        * fast/canvas/canvas-clearRect.html: Added.
     15        * fast/canvas/canvas-fillRect-expected.txt: Added.
     16        * fast/canvas/canvas-fillRect.html: Added.
     17        * fast/canvas/canvas-modify-emptyPath-expected.txt:
     18        * fast/canvas/canvas-strokeRect-expected.txt: Updated results.
     19        * fast/canvas/script-tests/canvas-clearRect.js: Added.
     20        * fast/canvas/script-tests/canvas-fillRect.js: Added.
     21        * fast/canvas/script-tests/canvas-modify-emptyPath.js: Added test case.
     22        * fast/canvas/script-tests/canvas-strokeRect.js: Ditto. Also, added
     23        debug statements so as to distinguish the results for each test.
     24
    1252010-04-27  Simon Fraser  <simon.fraser@apple.com>
    226
  • trunk/LayoutTests/fast/canvas/canvas-modify-emptyPath-expected.txt

    r45973 r58381  
    66Test lineTo
    77PASS getColor(40,40) is [0,128,0,255]
     8Test canvas.rect() with width = height = 0.
     9PASS getColor(1,1) is [0,0,0,0]
    810Test lineTo sequence
    911PASS getColor(0,0) is [255,0,0,255]
  • trunk/LayoutTests/fast/canvas/canvas-strokeRect-expected.txt

    r39080 r58381  
    44
    55
     6Test canvas.strokeRect() with solid green.
    67PASS imgdata[4] is 0
    78PASS imgdata[5] is 128
    89PASS imgdata[6] is 0
     10Test canvas.strokeRect() with a pattern.
    911PASS imgdata[4] is 0
    1012PASS imgdata[5] is 128
    1113PASS imgdata[6] is 0
     14Test canvas.strokeRect() with a gradient.
    1215PASS imgdata[4] is 0
    1316PASS imgdata[5] is 128
    1417PASS imgdata[6] is 0
     18Test canvas.strokeRect() with height = width = 0 and lineWidth = 2.
     19PASS imgdata[0] is 0
     20PASS imgdata[1] is 0
     21PASS imgdata[2] is 0
     22Test canvas.strokeRect() with height = width = 0, lineWidth = 2, and shadow.
     23PASS imgdata[0] is 0
     24PASS imgdata[1] is 0
     25PASS imgdata[2] is 0
    1526PASS successfullyParsed is true
    1627
  • trunk/LayoutTests/fast/canvas/script-tests/canvas-modify-emptyPath.js

    r48550 r58381  
    2222ctx.stroke();
    2323shouldBe("getColor(40,40)", "[0,128,0,255]");
     24ctx.clearRect(0, 0, 300, 300);
     25
     26// Test when create rectangle path using a rectangle with width = height = 0.
     27debug("Test canvas.rect() with width = height = 0.");
     28ctx.strokeStyle = 'red';
     29ctx.lineWidth = 10;
     30ctx.beginPath();
     31ctx.rect(0, 0, 0, 0);
     32ctx.stroke();
     33shouldBe("getColor(1,1)", "[0,0,0,0]");
    2434ctx.clearRect(0, 0, 300, 300);
    2535
  • trunk/LayoutTests/fast/canvas/script-tests/canvas-strokeRect.js

    r48550 r58381  
    33
    44// stroke rect with solid green
     5debug("Test canvas.strokeRect() with solid green.");
    56ctx.beginPath();
    67ctx.strokeStyle = 'green';
     
    1617
    1718// stroke rect with a pattern
     19debug("Test canvas.strokeRect() with a pattern.");
    1820var canvas2 = document.createElement('canvas');
    1921canvas2.width = 100;
     
    3537
    3638// stroke rect with gradient
     39debug("Test canvas.strokeRect() with a gradient.");
    3740var gradient = ctx.createLinearGradient(0, 0, 0, 100);
    3841gradient.addColorStop(0, "green");
     
    4750shouldBe("imgdata[6]", "0");
    4851
     52ctx.clearRect(0, 0, 100, 100);
     53
     54// stroke rect with height = width = 0 and lineWidth = 2.
     55debug("Test canvas.strokeRect() with height = width = 0 and lineWidth = 2.");
     56ctx.strokeStyle = 'red';
     57ctx.lineWidth = 2;
     58ctx.strokeRect(0, 0, 0, 0);
     59imageData = ctx.getImageData(0, 0, 1, 1);
     60imgdata = imageData.data;
     61shouldBe("imgdata[0]", "0");
     62shouldBe("imgdata[1]", "0");
     63shouldBe("imgdata[2]", "0");
     64
     65// stroke rect with height = width = 0, lineWidth = 2, and shadow.
     66debug("Test canvas.strokeRect() with height = width = 0, lineWidth = 2, and shadow.");
     67ctx.shadowOffsetX = 5;
     68ctx.shadowOffsetY = 5;
     69ctx.shadowColor = 'blue';
     70ctx.strokeStyle = 'red';
     71ctx.lineWidth = 2;
     72ctx.strokeRect(0, 0, 0, 0);
     73imageData = ctx.getImageData(0, 0, 1, 1);
     74imgdata = imageData.data;
     75shouldBe("imgdata[0]", "0");
     76shouldBe("imgdata[1]", "0");
     77shouldBe("imgdata[2]", "0");
     78
    4979var successfullyParsed = true;
  • trunk/WebCore/ChangeLog

    r58379 r58381  
     12010-04-27  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=37686
     6
     7        Fixes an issue where the canvas method strokeRect will stroke a
     8        rectangle whose dimensions are 0 when lineWidth > 1.
     9
     10        As per the definition of strokeRect in the HTML Canvas 2D Context
     11        spec. <http://www.w3.org/TR/2dcontext/#dom-context-2d-strokerect>,
     12        this method should have no effect when both the height and width
     13        are zero.
     14
     15        Tests: fast/canvas/canvas-clearRect.html
     16               fast/canvas/canvas-fillRect.html
     17
     18        * html/canvas/CanvasRenderingContext2D.cpp:
     19        (WebCore::validateRectForCanvas): Return false if height, width == 0.
     20
    1212010-04-27  Adam Barth  <abarth@webkit.org>
    222
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r57889 r58381  
    616616    if (!isfinite(x) | !isfinite(y) | !isfinite(width) | !isfinite(height))
    617617        return false;
    618    
     618
     619    if (!width && !height)
     620        return false;
     621
    619622    if (width < 0) {
    620623        width = -width;
Note: See TracChangeset for help on using the changeset viewer.